Home | History | Annotate | Download | only in class.copy
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 struct ConstCopy {
      4   ConstCopy();
      5   ConstCopy &operator=(const ConstCopy&);
      6 };
      7 
      8 struct NonConstCopy {
      9   NonConstCopy();
     10   NonConstCopy &operator=(NonConstCopy&);
     11 };
     12 
     13 struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
     14   VirtualInheritsNonConstCopy();
     15   VirtualInheritsNonConstCopy &operator=(const VirtualInheritsNonConstCopy&);
     16 };
     17 
     18 struct ImplicitNonConstCopy1 : NonConstCopy {  // expected-note{{the implicit copy assignment operator}}
     19   ImplicitNonConstCopy1();
     20 };
     21 
     22 struct ImplicitNonConstCopy2 { // expected-note{{the implicit copy assignment operator}}
     23   ImplicitNonConstCopy2();
     24   NonConstCopy ncc;
     25 };
     26 
     27 struct ImplicitNonConstCopy3 { // expected-note{{the implicit copy assignment operator}}
     28   ImplicitNonConstCopy3();
     29   NonConstCopy ncc_array[2][3];
     30 };
     31 
     32 struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy {
     33   ImplicitNonConstCopy4();
     34 };
     35 
     36 void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
     37                          const ImplicitNonConstCopy2 &cincc2,
     38                          const ImplicitNonConstCopy3 &cincc3,
     39                          const ImplicitNonConstCopy4 &cincc4,
     40                          const VirtualInheritsNonConstCopy &vincc) {
     41   (void)sizeof(ImplicitNonConstCopy1() = cincc1); // expected-error{{no viable overloaded '='}}
     42   (void)sizeof(ImplicitNonConstCopy2() = cincc2); // expected-error{{no viable overloaded '='}}
     43   (void)sizeof(ImplicitNonConstCopy3() = cincc3); // expected-error{{no viable overloaded '='}}
     44   (void)sizeof(ImplicitNonConstCopy4() = cincc4); // okay
     45   (void)sizeof(VirtualInheritsNonConstCopy() = vincc);
     46 }
     47