blob: 17933c2f009a1b385441755ac6b01b31c70bca09 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Sean Huntbe631222011-05-17 20:44:43 +00002
3struct non_copiable {
4 non_copiable(const non_copiable&) = delete; // expected-note {{marked deleted here}}
5 non_copiable& operator = (const non_copiable&) = delete; // expected-note {{explicitly deleted}}
6 non_copiable() = default;
7};
8
9struct non_const_copy {
10 non_const_copy(non_const_copy&) = default; // expected-note {{not viable}}
11 non_const_copy& operator = (non_const_copy&) & = default; // expected-note {{not viable}}
12 non_const_copy& operator = (non_const_copy&) && = default; // expected-note {{not viable}}
13 non_const_copy() = default; // expected-note {{not viable}}
14};
15
16void fn1 () {
17 non_copiable nc;
18 non_copiable nc2 = nc; // expected-error {{deleted constructor}}
19 nc = nc; // expected-error {{deleted operator}}
20
21 non_const_copy ncc;
22 non_const_copy ncc2 = ncc;
23 ncc = ncc2;
24 const non_const_copy cncc;
25 non_const_copy ncc3 = cncc; // expected-error {{no matching}}
26 ncc = cncc; // expected-error {{no viable overloaded}}
27};
28
29struct non_const_derived : non_const_copy {
30 non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}}
31 non_const_derived& operator =(non_const_derived&) = default;
32};
33
34struct bad_decls {
35 bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}}
36 bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}}
37 bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}}
Richard Smith55dec862011-09-30 00:45:47 +000038 bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}}
Sean Huntbe631222011-05-17 20:44:43 +000039};
40
41struct A {}; struct B {};
42
43struct except_spec_a {
44 virtual ~except_spec_a() throw(A);
45 except_spec_a() throw(A);
46};
47struct except_spec_b {
48 virtual ~except_spec_b() throw(B);
49 except_spec_b() throw(B);
50};
51
52struct except_spec_d_good : except_spec_a, except_spec_b {
53 ~except_spec_d_good();
54};
55except_spec_d_good::~except_spec_d_good() = default;
56// FIXME: This should error in the virtual override check.
57// It doesn't because we generate the implicit specification later than
58// appropriate.
59struct except_spec_d_bad : except_spec_a, except_spec_b {
60 ~except_spec_d_bad() = default;
61};
62
63// FIXME: This should error because the exceptions spec doesn't match.
64struct except_spec_d_mismatch : except_spec_a, except_spec_b {
65 except_spec_d_mismatch() throw(A) = default;
66};
67struct except_spec_d_match : except_spec_a, except_spec_b {
68 except_spec_d_match() throw(A, B) = default;
69};