xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/template-id-printing.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -ast-print %s | FileCheck %s
2*f4a2713aSLionel Sambuc namespace N {
3*f4a2713aSLionel Sambuc   template<typename T, typename U> void f(U);
4*f4a2713aSLionel Sambuc   template<int> void f();
5*f4a2713aSLionel Sambuc }
6*f4a2713aSLionel Sambuc 
g()7*f4a2713aSLionel Sambuc void g() {
8*f4a2713aSLionel Sambuc   // CHECK: N::f<int>(3.14
9*f4a2713aSLionel Sambuc   N::f<int>(3.14);
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc   // CHECK: N::f<double>
12*f4a2713aSLionel Sambuc   void (*fp)(int) = N::f<double>;
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc // (NNS qualified) DeclRefExpr.
17*f4a2713aSLionel Sambuc namespace DRE {
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc template <typename T>
20*f4a2713aSLionel Sambuc void foo();
21*f4a2713aSLionel Sambuc 
test()22*f4a2713aSLionel Sambuc void test() {
23*f4a2713aSLionel Sambuc   // CHECK: DRE::foo<int>;
24*f4a2713aSLionel Sambuc   DRE::foo<int>;
25*f4a2713aSLionel Sambuc   // CHECK: DRE::template foo<int>;
26*f4a2713aSLionel Sambuc   DRE::template foo<int>;
27*f4a2713aSLionel Sambuc   // CHECK: DRE::foo<int>();
28*f4a2713aSLionel Sambuc   DRE::foo<int>();
29*f4a2713aSLionel Sambuc   // CHECK: DRE::template foo<int>();
30*f4a2713aSLionel Sambuc   DRE::template foo<int>();
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc } // namespace DRE
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc // MemberExpr.
37*f4a2713aSLionel Sambuc namespace ME {
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc struct S {
40*f4a2713aSLionel Sambuc   template <typename T>
41*f4a2713aSLionel Sambuc   void mem();
42*f4a2713aSLionel Sambuc };
43*f4a2713aSLionel Sambuc 
test()44*f4a2713aSLionel Sambuc void test() {
45*f4a2713aSLionel Sambuc   S s;
46*f4a2713aSLionel Sambuc   // CHECK: s.mem<int>();
47*f4a2713aSLionel Sambuc   s.mem<int>();
48*f4a2713aSLionel Sambuc   // CHECK: s.template mem<int>();
49*f4a2713aSLionel Sambuc   s.template mem<int>();
50*f4a2713aSLionel Sambuc }
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc } // namespace ME
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc // UnresolvedLookupExpr.
56*f4a2713aSLionel Sambuc namespace ULE {
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc template <typename T>
59*f4a2713aSLionel Sambuc int foo();
60*f4a2713aSLionel Sambuc 
61*f4a2713aSLionel Sambuc template <typename T>
test()62*f4a2713aSLionel Sambuc void test() {
63*f4a2713aSLionel Sambuc   // CHECK: ULE::foo<T>;
64*f4a2713aSLionel Sambuc   ULE::foo<T>;
65*f4a2713aSLionel Sambuc   // CHECK: ULE::template foo<T>;
66*f4a2713aSLionel Sambuc   ULE::template foo<T>;
67*f4a2713aSLionel Sambuc }
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc } // namespace ULE
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc 
72*f4a2713aSLionel Sambuc // UnresolvedMemberExpr.
73*f4a2713aSLionel Sambuc namespace UME {
74*f4a2713aSLionel Sambuc 
75*f4a2713aSLionel Sambuc struct S {
76*f4a2713aSLionel Sambuc   template <typename T>
77*f4a2713aSLionel Sambuc   void mem();
78*f4a2713aSLionel Sambuc };
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc template <typename U>
test()81*f4a2713aSLionel Sambuc void test() {
82*f4a2713aSLionel Sambuc   S s;
83*f4a2713aSLionel Sambuc   // CHECK: s.mem<U>();
84*f4a2713aSLionel Sambuc   s.mem<U>();
85*f4a2713aSLionel Sambuc   // CHECK: s.template mem<U>();
86*f4a2713aSLionel Sambuc   s.template mem<U>();
87*f4a2713aSLionel Sambuc }
88*f4a2713aSLionel Sambuc 
89*f4a2713aSLionel Sambuc } // namespace UME
90*f4a2713aSLionel Sambuc 
91*f4a2713aSLionel Sambuc 
92*f4a2713aSLionel Sambuc // DependentScopeDeclRefExpr.
93*f4a2713aSLionel Sambuc namespace DSDRE {
94*f4a2713aSLionel Sambuc 
95*f4a2713aSLionel Sambuc template <typename T>
96*f4a2713aSLionel Sambuc struct S;
97*f4a2713aSLionel Sambuc 
98*f4a2713aSLionel Sambuc template <typename T>
test()99*f4a2713aSLionel Sambuc void test() {
100*f4a2713aSLionel Sambuc   // CHECK: S<T>::foo;
101*f4a2713aSLionel Sambuc   S<T>::foo;
102*f4a2713aSLionel Sambuc   // CHECK: S<T>::template foo;
103*f4a2713aSLionel Sambuc   S<T>::template foo;
104*f4a2713aSLionel Sambuc   // CHECK: S<T>::template foo<>;
105*f4a2713aSLionel Sambuc   S<T>::template foo<>;
106*f4a2713aSLionel Sambuc   // CHECK: S<T>::template foo<T>;
107*f4a2713aSLionel Sambuc   S<T>::template foo<T>;
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc 
110*f4a2713aSLionel Sambuc } // namespace DSDRE
111*f4a2713aSLionel Sambuc 
112*f4a2713aSLionel Sambuc 
113*f4a2713aSLionel Sambuc // DependentScopeMemberExpr.
114*f4a2713aSLionel Sambuc namespace DSME {
115*f4a2713aSLionel Sambuc 
116*f4a2713aSLionel Sambuc template <typename T>
117*f4a2713aSLionel Sambuc struct S;
118*f4a2713aSLionel Sambuc 
119*f4a2713aSLionel Sambuc template <typename T>
test()120*f4a2713aSLionel Sambuc void test() {
121*f4a2713aSLionel Sambuc   S<T> s;
122*f4a2713aSLionel Sambuc   // CHECK: s.foo;
123*f4a2713aSLionel Sambuc   s.foo;
124*f4a2713aSLionel Sambuc   // CHECK: s.template foo;
125*f4a2713aSLionel Sambuc   s.template foo;
126*f4a2713aSLionel Sambuc   // CHECK: s.template foo<>;
127*f4a2713aSLionel Sambuc   s.template foo<>;
128*f4a2713aSLionel Sambuc   // CHECK: s.template foo<T>;
129*f4a2713aSLionel Sambuc   s.template foo<T>;
130*f4a2713aSLionel Sambuc }
131*f4a2713aSLionel Sambuc 
132*f4a2713aSLionel Sambuc } // namespace DSME
133*f4a2713aSLionel Sambuc 
134*f4a2713aSLionel Sambuc namespace DSDRE_withImplicitTemplateArgs {
135*f4a2713aSLionel Sambuc 
foo()136*f4a2713aSLionel Sambuc template <typename T> void foo() {
137*f4a2713aSLionel Sambuc   // CHECK: T::template bar();
138*f4a2713aSLionel Sambuc   T::template bar();
139*f4a2713aSLionel Sambuc }
140*f4a2713aSLionel Sambuc 
141*f4a2713aSLionel Sambuc } // namespace DSDRE_withImplicitTemplateArgs
142