xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/partial-spec-instantiate.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR4607
4*f4a2713aSLionel Sambuc template <class T> struct X {};
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc template <> struct X<char>
7*f4a2713aSLionel Sambuc {
8*f4a2713aSLionel Sambuc   static char* g();
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc template <class T> struct X2 {};
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc template <class U>
14*f4a2713aSLionel Sambuc struct X2<U*> {
fX215*f4a2713aSLionel Sambuc   static void f() {
16*f4a2713aSLionel Sambuc     X<U>::g();
17*f4a2713aSLionel Sambuc   }
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
a(char * a,char * b)20*f4a2713aSLionel Sambuc void a(char *a, char *b) {X2<char*>::f();}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc namespace WonkyAccess {
23*f4a2713aSLionel Sambuc   template<typename T>
24*f4a2713aSLionel Sambuc   struct X {
25*f4a2713aSLionel Sambuc     int m;
26*f4a2713aSLionel Sambuc   };
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc   template<typename U>
29*f4a2713aSLionel Sambuc   class Y;
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   template<typename U>
32*f4a2713aSLionel Sambuc   struct Y<U*> : X<U> { };
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   template<>
35*f4a2713aSLionel Sambuc   struct Y<float*> : X<float> { };
36*f4a2713aSLionel Sambuc 
f(Y<int * > y,Y<float * > y2)37*f4a2713aSLionel Sambuc   int f(Y<int*> y, Y<float*> y2) {
38*f4a2713aSLionel Sambuc     return y.m + y2.m;
39*f4a2713aSLionel Sambuc   }
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc // <rdar://problem/9169404>
43*f4a2713aSLionel Sambuc namespace rdar9169404 {
44*f4a2713aSLionel Sambuc   template<typename T, T N> struct X { };
45*f4a2713aSLionel Sambuc   template<bool C> struct X<bool, C> {
46*f4a2713aSLionel Sambuc     typedef int type;
47*f4a2713aSLionel Sambuc   };
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc   X<bool, -1>::type value;
50*f4a2713aSLionel Sambuc }
51