• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -ast-print %s > %t
2 // RUN: FileCheck < %t %s -check-prefix=CHECK1
3 // RUN: FileCheck < %t %s -check-prefix=CHECK2
4 
5 template <int X, typename Y, int Z = 5>
6 struct foo {
7   int constant;
foofoo8   foo() {}
getSumfoo9   Y getSum() { return Y(X + Z); }
10 };
11 
12 template <int A, typename B>
bar()13 B bar() {
14   return B(A);
15 }
16 
baz()17 void baz() {
18   int x = bar<5, int>();
19   int y = foo<5, int>().getSum();
20   double z = foo<2, double, 3>().getSum();
21 }
22 
23 // Template instantiation - foo
24 // Since the order of instantiation may vary during runs, run FileCheck twice
25 // to make sure each instantiation is in the correct spot.
26 // CHECK1: template <int X = 5, typename Y = int, int Z = 5> struct foo {
27 // CHECK2: template <int X = 2, typename Y = double, int Z = 3> struct foo {
28 
29 // Template definition - foo
30 // CHECK1: template <int X, typename Y, int Z = 5> struct foo {
31 // CHECK2: template <int X, typename Y, int Z = 5> struct foo {
32 
33 // Template instantiation - bar
34 // CHECK1: template <int A = 5, typename B = int> int bar()
35 // CHECK2: template <int A = 5, typename B = int> int bar()
36 
37 // Template definition - bar
38 // CHECK1: template <int A, typename B> B bar()
39 // CHECK2: template <int A, typename B> B bar()
40