diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CXX/special/class.copy/p28-cxx11.cpp | 19 | ||||
-rw-r--r-- | test/CodeGenCXX/temporaries.cpp | 21 |
2 files changed, 40 insertions, 0 deletions
diff --git a/test/CXX/special/class.copy/p28-cxx11.cpp b/test/CXX/special/class.copy/p28-cxx11.cpp new file mode 100644 index 0000000000..dc501d91f7 --- /dev/null +++ b/test/CXX/special/class.copy/p28-cxx11.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++98 %s -fsyntax-only +// RUN: %clang_cc1 -std=c++11 %s -verify + +// In C++11, we must perform overload resolution to determine which function is +// called by a defaulted assignment operator, and the selected operator might +// not be a copy or move assignment (it might be a specialization of a templated +// 'operator=', for instance). +struct A { + A &operator=(const A &); + + template<typename T> + A &operator=(T &&) { return T::error; } // expected-error {{no member named 'error' in 'A'}} +}; + +struct B : A { + B &operator=(B &&); +}; + +B &B::operator=(B &&) = default; // expected-note {{here}} diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp index e90c94796f..a369c2e369 100644 --- a/test/CodeGenCXX/temporaries.cpp +++ b/test/CodeGenCXX/temporaries.cpp @@ -537,3 +537,24 @@ namespace PR11365 { (void) (A [3]) {}; } } + +namespace AssignmentOp { + struct A { ~A(); }; + struct B { A operator=(const B&); }; + struct C : B { B b1, b2; }; + // CHECK: define void @_ZN12AssignmentOp1fE + void f(C &c1, const C &c2) { + // CHECK: call {{.*}} @_ZN12AssignmentOp1CaSERKS0_( + c1 = c2; + } + + // Ensure that each 'A' temporary is destroyed before the next subobject is + // copied. + // CHECK: define {{.*}} @_ZN12AssignmentOp1CaSERKS0_( + // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS + // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( + // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS + // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( + // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS + // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( +} |