| Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s | 
| Anders Carlsson | 7055394 | 2009-08-29 05:16:22 +0000 | [diff] [blame] | 2 |  | 
|  | 3 | template<typename T> struct A { | 
| Douglas Gregor | 7ae2d77 | 2010-01-31 09:12:51 +0000 | [diff] [blame] | 4 | A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}} | 
| Anders Carlsson | 7055394 | 2009-08-29 05:16:22 +0000 | [diff] [blame] | 5 |  | 
|  | 6 | T a; | 
|  | 7 | }; | 
|  | 8 |  | 
|  | 9 | A<int> a0; | 
|  | 10 | A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}} | 
|  | 11 |  | 
|  | 12 | template<typename T> struct B { | 
| John McCall | bb7b658 | 2010-04-10 07:37:23 +0000 | [diff] [blame] | 13 | B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}} | 
|  | 14 | a(2) { } | 
| Anders Carlsson | 7055394 | 2009-08-29 05:16:22 +0000 | [diff] [blame] | 15 |  | 
|  | 16 | int a; | 
|  | 17 | int b; | 
|  | 18 | }; | 
|  | 19 |  | 
| Anders Carlsson | db0a965 | 2010-04-02 06:26:44 +0000 | [diff] [blame] | 20 | B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}} | 
| Eli Friedman | 15e0526 | 2009-08-29 22:22:07 +0000 | [diff] [blame] | 21 |  | 
|  | 22 | template <class T> struct AA { AA(int); }; | 
|  | 23 | template <class T> class BB : public AA<T> { | 
| John McCall | 3155f57 | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 24 | public: | 
| Eli Friedman | 15e0526 | 2009-08-29 22:22:07 +0000 | [diff] [blame] | 25 | BB() : AA<T>(1) {} | 
|  | 26 | }; | 
|  | 27 | BB<int> x; | 
| Richard Smith | 503053a | 2012-12-19 02:27:38 +0000 | [diff] [blame] | 28 |  | 
|  | 29 | struct X { | 
|  | 30 | X(); | 
|  | 31 | }; | 
|  | 32 | template<typename T> | 
|  | 33 | struct Y { | 
|  | 34 | Y() : x() {} | 
|  | 35 | X x; | 
|  | 36 | }; | 
|  | 37 | Y<int> y; | 
| Richard Smith | 38a549b | 2012-12-21 08:13:35 +0000 | [diff] [blame] | 38 |  | 
|  | 39 | template<typename T> struct Array { | 
|  | 40 | int a[3]; | 
|  | 41 | Array() : a() {} | 
|  | 42 | }; | 
|  | 43 | Array<int> s; |