• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 struct IntHolder { // expected-note{{here}} // expected-note 2{{candidate constructor (the implicit copy constructor)}}
4   IntHolder(int); // expected-note 2{{candidate constructor}}
5 };
6 
7 template<typename T, typename U>
8 struct X { // expected-note{{here}}
fX9   void f() {
10     T t; // expected-error{{no matching}}
11   }
12 
gX13   void g() { }
14 
15   struct Inner {  // expected-error{{implicit default}}
16     T value; 	// expected-note {{member is declared here}}
17   };
18 
19   static T value;
20 };
21 
22 template<typename T, typename U>
23 T X<T, U>::value; // expected-error{{no matching constructor}}
24 
test_X_IntHolderInt(X<IntHolder,int> xih)25 IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) {
26   xih.g(); // okay
27   xih.f(); // expected-note{{instantiation}}
28 
29   X<IntHolder, int>::Inner inner; // expected-note {{first required here}}
30 
31   return X<IntHolder, int>::value; // expected-note{{instantiation}}
32 }
33 
34 // Explicitly specialize the members of X<IntHolder, long> to not cause
35 // problems with instantiation.
36 template<>
f()37 void X<IntHolder, long>::f() { }
38 
39 template<>
40 struct X<IntHolder, long>::Inner {
InnerX::Inner41   Inner() : value(17) { }
42   IntHolder value;
43 };
44 
45 template<>
46 IntHolder X<IntHolder, long>::value = 17;
47 
test_X_IntHolderInt(X<IntHolder,long> xih)48 IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) {
49   xih.g(); // okay
50   xih.f(); // okay, uses specialization
51 
52   X<IntHolder, long>::Inner inner; // okay, uses specialization
53 
54   return X<IntHolder, long>::value; // okay, uses specialization
55 }
56 
57 template<>
X()58 X<IntHolder, long>::X() { } // expected-error{{instantiated member}}
59