xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-member-initializers.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc template<typename T> struct A {
AA4*f4a2713aSLionel Sambuc   A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc   T a;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc A<int> a0;
10*f4a2713aSLionel Sambuc A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc template<typename T> struct B {
BB13*f4a2713aSLionel Sambuc   B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
14*f4a2713aSLionel Sambuc     a(2) { }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc   int a;
17*f4a2713aSLionel Sambuc   int b;
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc template <class T> struct AA { AA(int); };
23*f4a2713aSLionel Sambuc template <class T> class BB : public AA<T> {
24*f4a2713aSLionel Sambuc public:
BB()25*f4a2713aSLionel Sambuc   BB() : AA<T>(1) {}
26*f4a2713aSLionel Sambuc };
27*f4a2713aSLionel Sambuc BB<int> x;
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc struct X {
30*f4a2713aSLionel Sambuc   X();
31*f4a2713aSLionel Sambuc };
32*f4a2713aSLionel Sambuc template<typename T>
33*f4a2713aSLionel Sambuc struct Y {
YY34*f4a2713aSLionel Sambuc   Y() : x() {}
35*f4a2713aSLionel Sambuc   X x;
36*f4a2713aSLionel Sambuc };
37*f4a2713aSLionel Sambuc Y<int> y;
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc template<typename T> struct Array {
40*f4a2713aSLionel Sambuc   int a[3];
ArrayArray41*f4a2713aSLionel Sambuc   Array() : a() {}
42*f4a2713aSLionel Sambuc };
43*f4a2713aSLionel Sambuc Array<int> s;
44