[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / special / class.copy / p20.cpp
blob4f17879ecfb70fc0f46f20d10ff185b26ffac101
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4 struct ConstCopy {
5 ConstCopy();
6 ConstCopy &operator=(const ConstCopy&);
7 };
9 struct NonConstCopy {
10 NonConstCopy();
11 NonConstCopy &operator=(NonConstCopy&);
14 struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
15 VirtualInheritsNonConstCopy();
16 VirtualInheritsNonConstCopy &operator=(const VirtualInheritsNonConstCopy&);
19 struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note{{the implicit copy assignment operator}}
20 ImplicitNonConstCopy1();
23 struct ImplicitNonConstCopy2 { // expected-note{{the implicit copy assignment operator}}
24 ImplicitNonConstCopy2();
25 NonConstCopy ncc;
28 struct ImplicitNonConstCopy3 { // expected-note{{the implicit copy assignment operator}}
29 ImplicitNonConstCopy3();
30 NonConstCopy ncc_array[2][3];
33 struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy {
34 ImplicitNonConstCopy4();
37 void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
38 const ImplicitNonConstCopy2 &cincc2,
39 const ImplicitNonConstCopy3 &cincc3,
40 const ImplicitNonConstCopy4 &cincc4,
41 const VirtualInheritsNonConstCopy &vincc) {
42 (void)sizeof(ImplicitNonConstCopy1() = cincc1); // expected-error{{no viable overloaded '='}}
43 (void)sizeof(ImplicitNonConstCopy2() = cincc2); // expected-error{{no viable overloaded '='}}
44 (void)sizeof(ImplicitNonConstCopy3() = cincc3); // expected-error{{no viable overloaded '='}}
45 (void)sizeof(ImplicitNonConstCopy4() = cincc4); // okay
46 (void)sizeof(VirtualInheritsNonConstCopy() = vincc);