2011-10-14 06:29:44 +08:00
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2011-05-18 04:44:43 +08:00
struct non_copiable {
non_copiable ( const non_copiable & ) = delete ; // expected-note {{marked deleted here}}
non_copiable & operator = ( const non_copiable & ) = delete ; // expected-note {{explicitly deleted}}
non_copiable ( ) = default ;
} ;
struct non_const_copy {
2012-05-15 12:39:51 +08:00
non_const_copy ( non_const_copy & ) ;
non_const_copy & operator = ( non_const_copy & ) & ;
non_const_copy & operator = ( non_const_copy & ) & & ;
2011-05-18 04:44:43 +08:00
non_const_copy ( ) = default ; // expected-note {{not viable}}
} ;
2012-05-15 12:39:51 +08:00
non_const_copy : : non_const_copy ( non_const_copy & ) = default ; // expected-note {{not viable}}
non_const_copy & non_const_copy : : operator = ( non_const_copy & ) & = default ; // expected-note {{not viable}}
non_const_copy & non_const_copy : : operator = ( non_const_copy & ) & & = default ; // expected-note {{not viable}}
2011-05-18 04:44:43 +08:00
void fn1 ( ) {
non_copiable nc ;
non_copiable nc2 = nc ; // expected-error {{deleted constructor}}
nc = nc ; // expected-error {{deleted operator}}
non_const_copy ncc ;
non_const_copy ncc2 = ncc ;
ncc = ncc2 ;
2012-08-01 06:40:31 +08:00
const non_const_copy cncc { } ;
const non_const_copy cncc1 ; // expected-error {{default initialization of an object of const type 'const non_const_copy' requires a user-provided default constructor}}
2011-05-18 04:44:43 +08:00
non_const_copy ncc3 = cncc ; // expected-error {{no matching}}
ncc = cncc ; // expected-error {{no viable overloaded}}
} ;
struct non_const_derived : non_const_copy {
non_const_derived ( const non_const_derived & ) = default ; // expected-error {{requires it to be non-const}}
non_const_derived & operator = ( non_const_derived & ) = default ;
} ;
struct bad_decls {
2012-12-08 10:53:02 +08:00
bad_decls ( volatile bad_decls & ) = default ; // expected-error {{may not be volatile}}
2012-05-15 12:39:51 +08:00
bad_decls & & operator = ( bad_decls ) = default ; // expected-error {{lvalue reference}} expected-error {{must return 'bad_decls &'}}
2012-12-08 10:53:02 +08:00
bad_decls & operator = ( volatile bad_decls & ) = default ; // expected-error {{may not be volatile}}
2011-09-30 08:45:47 +08:00
bad_decls & operator = ( const bad_decls & ) const = default ; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}}
2011-05-18 04:44:43 +08:00
} ;
struct A { } ; struct B { } ;
struct except_spec_a {
virtual ~ except_spec_a ( ) throw ( A ) ;
except_spec_a ( ) throw ( A ) ;
} ;
struct except_spec_b {
virtual ~ except_spec_b ( ) throw ( B ) ;
except_spec_b ( ) throw ( B ) ;
} ;
struct except_spec_d_good : except_spec_a , except_spec_b {
~ except_spec_d_good ( ) ;
} ;
except_spec_d_good : : ~ except_spec_d_good ( ) = default ;
2012-12-08 10:53:02 +08:00
struct except_spec_d_good2 : except_spec_a , except_spec_b {
~ except_spec_d_good2 ( ) = default ;
} ;
2011-05-18 04:44:43 +08:00
struct except_spec_d_bad : except_spec_a , except_spec_b {
2012-12-08 10:53:02 +08:00
~ except_spec_d_bad ( ) noexcept ;
2011-05-18 04:44:43 +08:00
} ;
2012-12-08 10:53:02 +08:00
// FIXME: This should error because this exception spec is not
// compatible with the implicit exception spec.
except_spec_d_bad : : ~ except_spec_d_bad ( ) noexcept = default ;
2011-05-18 04:44:43 +08:00
2012-12-08 10:53:02 +08:00
// FIXME: This should error because this exception spec is not
// compatible with the implicit exception spec.
2011-05-18 04:44:43 +08:00
struct except_spec_d_mismatch : except_spec_a , except_spec_b {
except_spec_d_mismatch ( ) throw ( A ) = default ;
} ;
struct except_spec_d_match : except_spec_a , except_spec_b {
except_spec_d_match ( ) throw ( A , B ) = default ;
2012-08-01 06:40:31 +08:00
} ;
2012-02-17 00:50:43 +08:00
// gcc-compatibility: allow attributes on default definitions
// (but not normal definitions)
struct S { S ( ) ; } ;
S : : S ( ) __attribute ( ( pure ) ) = default ;