diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Misc/ast-dump-templates.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Misc/ast-dump-templates.cpp')
-rw-r--r-- | clang/test/Misc/ast-dump-templates.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/Misc/ast-dump-templates.cpp b/clang/test/Misc/ast-dump-templates.cpp new file mode 100644 index 0000000..7d56e7b --- /dev/null +++ b/clang/test/Misc/ast-dump-templates.cpp @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -ast-dump %s > %t +// RUN: FileCheck < %t %s -check-prefix=CHECK1 +// RUN: FileCheck < %t %s -check-prefix=CHECK2 + +template <int X, typename Y, int Z = 5> +struct foo { + int constant; + foo() {} + Y getSum() { return Y(X + Z); } +}; + +template <int A, typename B> +B bar() { + return B(A); +} + +void baz() { + int x = bar<5, int>(); + int y = foo<5, int>().getSum(); + double z = foo<2, double, 3>().getSum(); +} + +// Template instantiation - foo +// Since the order of instantiation may vary during runs, run FileCheck twice +// to make sure each instantiation is in the correct spot. +// CHECK1: template <int X = 5, typename Y = int, int Z = 5> struct foo { +// CHECK2: template <int X = 2, typename Y = double, int Z = 3> struct foo { + +// Template definition - foo +// CHECK1: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5) +// CHECK2: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5) + +// Template instantiation - bar +// CHECK1: template <int A = 5, typename B = int> int bar() +// CHECK2: template <int A = 5, typename B = int> int bar() + +// Template definition - bar +// CHECK1: template <int A, typename B> B bar() +// CHECK2: template <int A, typename B> B bar() |