blob: 7d56e7b04eb2d195825590ad36f5fda996e9fc39 [file] [log] [blame]
Richard Trieu7efa0e02011-07-28 20:30:10 +00001// RUN: %clang_cc1 -ast-dump %s > %t
2// RUN: FileCheck < %t %s -check-prefix=CHECK1
3// RUN: FileCheck < %t %s -check-prefix=CHECK2
Richard Trieu5cb3d692011-07-28 00:19:05 +00004
5template <int X, typename Y, int Z = 5>
6struct foo {
7 int constant;
8 foo() {}
9 Y getSum() { return Y(X + Z); }
10};
11
12template <int A, typename B>
13B bar() {
14 return B(A);
15}
16
17void 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
Richard Trieu7efa0e02011-07-28 20:30:10 +000024// 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 {
Richard Trieu5cb3d692011-07-28 00:19:05 +000028
29// Template definition - foo
Richard Trieu7efa0e02011-07-28 20:30:10 +000030// CHECK1: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5)
31// CHECK2: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5)
Richard Trieu5cb3d692011-07-28 00:19:05 +000032
33// Template instantiation - bar
Richard Trieu7efa0e02011-07-28 20:30:10 +000034// CHECK1: template <int A = 5, typename B = int> int bar()
35// CHECK2: template <int A = 5, typename B = int> int bar()
Richard Trieu5cb3d692011-07-28 00:19:05 +000036
37// Template definition - bar
Richard Trieu7efa0e02011-07-28 20:30:10 +000038// CHECK1: template <int A, typename B> B bar()
39// CHECK2: template <int A, typename B> B bar()