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