1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s 2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 3 // RUN: %clang_cc1 -fsyntax-only -verify %s 4 5 struct IntHolder { // expected-note 0-1{{here}} expected-note 2-4{{candidate constructor (the implicit}} 6 IntHolder(int); // expected-note 2{{candidate constructor}} 7 }; 8 9 template<typename T, typename U> 10 struct X { // expected-note{{here}} 11 void f() { 12 T t; // expected-error{{no matching}} 13 } 14 15 void g() { } 16 17 struct Inner { 18 #if __cplusplus >= 201103L 19 T value; // expected-note {{has no default constructor}} 20 #else 21 // expected-error@-4 {{implicit default}} 22 T value; // expected-note {{member is declared here}} 23 #endif 24 }; 25 26 static T value; 27 }; 28 29 template<typename T, typename U> 30 T X<T, U>::value; // expected-error{{no matching constructor}} 31 32 IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) { 33 xih.g(); // okay 34 xih.f(); // expected-note{{instantiation}} 35 36 X<IntHolder, int>::Inner inner; 37 #if __cplusplus >= 201103L 38 // expected-error@-2 {{call to implicitly-deleted}} 39 #else 40 // expected-note@-4 {{first required here}} 41 #endif 42 43 return X<IntHolder, int>::value; // expected-note{{instantiation}} 44 } 45 46 // Explicitly specialize the members of X<IntHolder, long> to not cause 47 // problems with instantiation. 48 template<> 49 void X<IntHolder, long>::f() { } 50 51 template<> 52 struct X<IntHolder, long>::Inner { 53 Inner() : value(17) { } 54 IntHolder value; 55 }; 56 57 template<> 58 IntHolder X<IntHolder, long>::value = 17; 59 60 IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) { 61 xih.g(); // okay 62 xih.f(); // okay, uses specialization 63 64 X<IntHolder, long>::Inner inner; // okay, uses specialization 65 66 return X<IntHolder, long>::value; // okay, uses specialization 67 } 68 69 template<> 70 X<IntHolder, long>::X() { } // expected-error{{instantiated member}} 71