blob: 63862063acdfe6ee0b9b5c2722d2464221678f49 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
Anders Carlsson09025312009-08-29 05:16:22 +00002
3template<typename T> struct A {
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00004 A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
Anders Carlsson09025312009-08-29 05:16:22 +00005
6 T a;
7};
8
9A<int> a0;
10A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
11
12template<typename T> struct B {
John McCalld6ca8da2010-04-10 07:37:23 +000013 B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
14 a(2) { }
Anders Carlsson09025312009-08-29 05:16:22 +000015
16 int a;
17 int b;
18};
19
Anders Carlssonbcc12fd2010-04-02 06:26:44 +000020B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
Eli Friedmanc5573a82009-08-29 22:22:07 +000021
22template <class T> struct AA { AA(int); };
23template <class T> class BB : public AA<T> {
John McCall7002f4c2010-04-09 19:03:51 +000024public:
Eli Friedmanc5573a82009-08-29 22:22:07 +000025 BB() : AA<T>(1) {}
26};
27BB<int> x;
Richard Smithcd6d5f42012-12-19 02:27:38 +000028
29struct X {
30 X();
31};
32template<typename T>
33struct Y {
34 Y() : x() {}
35 X x;
36};
37Y<int> y;
Richard Smith5cf15892012-12-21 08:13:35 +000038
39template<typename T> struct Array {
40 int a[3];
41 Array() : a() {}
42};
43Array<int> s;