aboutsummaryrefslogtreecommitdiff
path: root/test/AST/ast-dump-templates.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /test/AST/ast-dump-templates.cpp
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
downloadsrc-676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63.tar.gz
src-676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63.zip
Vendor import of clang trunk r351319 (just before the release_80 branchvendor/clang/clang-trunk-r351319
Notes
Notes: svn path=/vendor/clang/dist/; revision=343173 svn path=/vendor/clang/clang-trunk-r351319/; revision=343174; tag=vendor/clang/clang-trunk-r351319
Diffstat (limited to 'test/AST/ast-dump-templates.cpp')
-rw-r--r--test/AST/ast-dump-templates.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/AST/ast-dump-templates.cpp b/test/AST/ast-dump-templates.cpp
new file mode 100644
index 000000000000..89feee75268a
--- /dev/null
+++ b/test/AST/ast-dump-templates.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++1z -ast-print %s > %t
+// RUN: FileCheck < %t %s -check-prefix=CHECK1
+// RUN: FileCheck < %t %s -check-prefix=CHECK2
+// RUN: %clang_cc1 -std=c++1z -ast-dump %s | FileCheck --check-prefix=DUMP %s
+
+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 definition - foo
+// CHECK1: template <int X, typename Y, int Z = 5> struct foo {
+// CHECK2: template <int X, typename Y, int Z = 5> struct foo {
+
+// 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<> struct foo<5, int, 5> {
+// CHECK2: template<> struct foo<2, double, 3> {
+
+// Template definition - bar
+// CHECK1: template <int A, typename B> B bar()
+// CHECK2: template <int A, typename B> B bar()
+
+// Template instantiation - bar
+// CHECK1: template<> int bar<5, int>()
+// CHECK2: template<> int bar<5, int>()
+
+// CHECK1-LABEL: template <typename ...T> struct A {
+// CHECK1-NEXT: template <T ...x[3]> struct B {
+template <typename ...T> struct A {
+ template <T ...x[3]> struct B {};
+};
+
+// CHECK1-LABEL: template <typename ...T> void f(T ...[3]) {
+// CHECK1-NEXT: A<T [3]...> a;
+template <typename ...T> void f(T ...[3]) {
+ A<T [3]...> a;
+}
+
+namespace test2 {
+void func(int);
+void func(float);
+template<typename T>
+void tmpl() {
+ func(T());
+}
+
+// DUMP: UnresolvedLookupExpr {{.*}} <col:3> '<overloaded function type>' lvalue (ADL) = 'func'
+}
+
+namespace test3 {
+ template<typename T> struct A {};
+ template<typename T> A(T) -> A<int>;
+ // CHECK1: template <typename T> A(T) -> A<int>;
+}