[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / instantiate-member-initializers.cpp
blob63862063acdfe6ee0b9b5c2722d2464221678f49
1 // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
3 template<typename T> struct A {
4 A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
6 T a;
7 };
9 A<int> a0;
10 A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
12 template<typename T> struct B {
13 B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
14 a(2) { }
16 int a;
17 int b;
20 B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
22 template <class T> struct AA { AA(int); };
23 template <class T> class BB : public AA<T> {
24 public:
25 BB() : AA<T>(1) {}
27 BB<int> x;
29 struct X {
30 X();
32 template<typename T>
33 struct Y {
34 Y() : x() {}
35 X x;
37 Y<int> y;
39 template<typename T> struct Array {
40 int a[3];
41 Array() : a() {}
43 Array<int> s;