From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/Misc/ast-dump-templates.cpp | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 clang/test/Misc/ast-dump-templates.cpp (limited to 'clang/test/Misc/ast-dump-templates.cpp') 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 +struct foo { + int constant; + foo() {} + Y getSum() { return Y(X + Z); } +}; + +template +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 struct foo { +// CHECK2: template struct foo { + +// Template definition - foo +// CHECK1: template int bar() +// CHECK2: template int bar() + +// Template definition - bar +// CHECK1: template B bar() +// CHECK2: template B bar() -- cgit v1.2.3