blob: 578d1e22ed5bc1492c072f9b55cb4091977a693b [file] [log] [blame]
Sean Hunt1f2f3842011-05-17 00:19:05 +00001// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
2
3struct non_trivial {
4 non_trivial();
5 non_trivial(const non_trivial&);
6 non_trivial& operator = (const non_trivial&);
7 ~non_trivial();
8};
9
10union bad_union { // expected-note {{marked deleted here}}
11 non_trivial nt;
12};
13bad_union u; // expected-error {{call to deleted constructor}}
14union bad_union2 { // expected-note {{marked deleted here}}
15 const int i;
16};
17bad_union2 u2; // expected-error {{call to deleted constructor}}
18
19struct bad_anon { // expected-note {{marked deleted here}}
20 union {
21 non_trivial nt;
22 };
23};
24bad_anon a; // expected-error {{call to deleted constructor}}
25struct bad_anon2 { // expected-note {{marked deleted here}}
26 union {
27 const int i;
28 };
29};
30bad_anon2 a2; // expected-error {{call to deleted constructor}}
31
32// This would be great except that we implement
33union good_union {
34 const int i;
35 float f;
36};
37good_union gu;
38struct good_anon {
39 union {
40 const int i;
41 float f;
42 };
43};
44good_anon ga;
45
46struct good : non_trivial {
47 non_trivial nt;
48};
49good g;
Sean Huntf1922d22011-05-17 20:44:39 +000050
51struct bad_const { // expected-note {{marked deleted here}}
52 const good g;
53};
54bad_const bc; // expected-error {{call to deleted constructor}}
55
56struct good_const {
57 const non_trivial nt;
58};
59good_const gc;
60
61struct no_default {
62 no_default() = delete;
63};
64struct no_dtor {
65 ~no_dtor() = delete;
66};
67
68struct bad_field_default { // expected-note {{marked deleted here}}
69 no_default nd;
70};
71bad_field_default bfd; // expected-error {{call to deleted constructor}}
72struct bad_base_default : no_default { // expected-note {{marked deleted here}}
73};
74bad_base_default bbd; // expected-error {{call to deleted constructor}}
75
76struct bad_field_dtor { // expected-note {{marked deleted here}}
77 no_dtor nd;
78};
79bad_field_dtor bfx; // expected-error {{call to deleted constructor}}
80struct bad_base_dtor : no_dtor { // expected-note {{marked deleted here}}
81};
82bad_base_dtor bbx; // expected-error {{call to deleted constructor}}
83
84struct ambiguous_default {
85 ambiguous_default();
86 ambiguous_default(int = 2);
87};
88struct has_amb_field { // expected-note {{marked deleted here}}
89 ambiguous_default ad;
90};
91has_amb_field haf; // expected-error {{call to deleted constructor}}
92
93// FIXME: This should fail due to deletion
94#if 0
95class inaccessible_default {
96 inaccessible_default();
97};
98struct has_inacc_field {
99 inaccessible_default id;
100};
101has_inacc_field hif;
102#endif
103
104class friend_default {
105 friend struct has_friend;
106 friend_default();
107};
108struct has_friend {
109 friend_default fd;
110};
111has_friend hf;
112
113struct defaulted_delete {
114 no_default nd;
115 defaulted_delete() = default; // expected-note {{marked deleted here}}
116};
117defaulted_delete dd; // expected-error {{call to deleted constructor}}
118
119struct late_delete {
120 no_default nd;
121 late_delete();
122};
123late_delete::late_delete() = default; // expected-error {{would delete it}}