brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 7b5697b Raw
135 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2 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 {11  non_trivial nt; // expected-note {{non-trivial default constructor}}12};13bad_union u; // expected-error {{call to implicitly-deleted default constructor}}14union bad_union2 { // expected-note {{all data members are const-qualified}}15  const int i;16};17bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}18 19struct bad_anon {20  union {21    non_trivial nt; // expected-note {{non-trivial default constructor}}22  };23};24bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}25struct bad_anon2 {26  union { // expected-note {{all data members of an anonymous union member are const-qualified}}27    const int i;28  };29};30bad_anon2 a2; // expected-error {{call to implicitly-deleted default constructor}}31 32// This would be great except that we implement33union 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;50 51struct bad_const_inner {52  int x;53};54 55struct bad_const {56  const bad_const_inner g; // expected-note {{field 'g' of const-qualified type 'const bad_const_inner' would not be initialized}}57};58bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}59 60struct good_const {61  const non_trivial nt;62};63good_const gc;64 65struct no_default {66  no_default() = delete; // expected-note 5{{deleted here}}67};68struct no_dtor {69  ~no_dtor() = delete; // expected-note 2{{deleted here}}70};71 72struct bad_field_default {73  no_default nd; // expected-note {{field 'nd' has a deleted default constructor}}74};75bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}76struct bad_base_default : no_default { // expected-note {{base class 'no_default' has a deleted default constructor}}77};78bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}79 80struct bad_field_dtor {81  no_dtor nd; // expected-note {{field 'nd' has a deleted destructor}}82};83bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}84struct bad_base_dtor : no_dtor { // expected-note {{base class 'no_dtor' has a deleted destructor}}85};86bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}87 88struct ambiguous_default {89  ambiguous_default();90  ambiguous_default(int = 2);91};92struct has_amb_field {93  ambiguous_default ad; // expected-note {{field 'ad' has multiple default constructors}}94};95has_amb_field haf; // expected-error {{call to implicitly-deleted default constructor}}96 97class inaccessible_default {98  inaccessible_default();99};100struct has_inacc_field {101  inaccessible_default id; // expected-note {{field 'id' has an inaccessible default constructor}}102};103has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}104 105class friend_default {106  friend struct has_friend;107  friend_default();108};109struct has_friend {110  friend_default fd;111};112has_friend hf;113 114struct defaulted_delete {115  no_default nd; // expected-note 2{{because field 'nd' has a deleted default constructor}}116  defaulted_delete() = default; // expected-note{{implicitly deleted here}} expected-warning {{implicitly deleted}} expected-note{{replace 'default'}}117};118defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}119 120struct late_delete {121  no_default nd; // expected-note {{because field 'nd' has a deleted default constructor}}122  late_delete();123};124late_delete::late_delete() = default; // expected-error {{would delete it}}125 126namespace empty {127  static union {}; // expected-warning {{does not declare anything}}128  static union { union {}; }; // expected-warning {{does not declare anything}}129  static union { struct {}; }; // expected-warning {{does not declare anything}}130  static union { union { union {}; }; }; // expected-warning {{does not declare anything}}131  static union { union { struct {}; }; }; // expected-warning {{does not declare anything}}132  static union { struct { union {}; }; }; // expected-warning {{does not declare anything}}133  static union { struct { struct {}; }; }; // expected-warning {{does not declare anything}}134}135