xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-scope.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -verify %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc template<typename ...T> struct X {
4*0a6a1f1dSLionel Sambuc   void f(int);
5*0a6a1f1dSLionel Sambuc   void f(...);
6*0a6a1f1dSLionel Sambuc   static int n;
7*0a6a1f1dSLionel Sambuc };
8*0a6a1f1dSLionel Sambuc 
9*0a6a1f1dSLionel Sambuc template<typename T, typename U> using A = T;
10*0a6a1f1dSLionel Sambuc 
11*0a6a1f1dSLionel Sambuc // These definitions are OK, X<A<T, decltype(...)>...> is equivalent to X<T...>
12*0a6a1f1dSLionel Sambuc // so this defines the member of the primary template.
13*0a6a1f1dSLionel Sambuc template<typename ...T>
f(int)14*0a6a1f1dSLionel Sambuc void X<A<T, decltype(f(T()))>...>::f(int) {} // expected-error {{undeclared}}
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc template<typename ...T>
17*0a6a1f1dSLionel Sambuc int X<A<T, decltype(f(T()))>...>::n = 0; // expected-error {{undeclared}}
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc struct Y {}; void f(Y);
20*0a6a1f1dSLionel Sambuc 
g()21*0a6a1f1dSLionel Sambuc void g() {
22*0a6a1f1dSLionel Sambuc   // OK, substitution succeeds.
23*0a6a1f1dSLionel Sambuc   X<Y>().f(0);
24*0a6a1f1dSLionel Sambuc   X<Y>::n = 1;
25*0a6a1f1dSLionel Sambuc 
26*0a6a1f1dSLionel Sambuc   // Error, substitution fails; this should not be treated as a SFINAE-able
27*0a6a1f1dSLionel Sambuc   // condition, so we don't select X<void>::f(...).
28*0a6a1f1dSLionel Sambuc   X<void>().f(0); // expected-note {{instantiation of}}
29*0a6a1f1dSLionel Sambuc   X<void>::n = 1; // expected-note {{instantiation of}}
30*0a6a1f1dSLionel Sambuc }
31