// 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 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 definition - foo // CHECK1: template struct foo { // CHECK2: template 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 B bar() // CHECK2: template B bar() // Template instantiation - bar // CHECK1: template<> int bar<5, int>() // CHECK2: template<> int bar<5, int>() // CHECK1-LABEL: template struct A { // CHECK1-NEXT: template struct B { template struct A { template struct B {}; }; // CHECK1-LABEL: template void f() { // CHECK1-NEXT: A a; template void f() { A a; } namespace test2 { void func(int); void func(float); template void tmpl() { func(T()); } // DUMP: UnresolvedLookupExpr {{.*}} '' lvalue (ADL) = 'func' } namespace test3 { template struct A {}; template A(T) -> A; // CHECK1: template A(T) -> A; } namespace test4 { template struct foo { static void fn(); }; // Prints using an "integral" template argument. Test that this correctly // includes the type for the auto argument and omits it for the fixed // type/unsigned argument (see // TemplateParameterList::shouldIncludeTypeForArgument) // CHECK1: {{^ }}template<> struct foo<0, 0L> { // CHECK1: {{^ }}void test(){{ }}{ // CHECK1: {{^ }}foo<0, 0 + 0L>::fn(); void test() { foo<0, 0 + 0L>::fn(); } // Prints using an "expression" template argument. This renders based on the way // the user wrote the arguments (including that + expression) - so it's not // powered by the shouldIncludeTypeForArgument functionality. // Not sure if this it's intentional that these two specializations are rendered // differently in this way. // CHECK1: {{^ }}template<> struct foo<1, 0 + 0L> { template struct foo<1, 0 + 0L>; } namespace test5 { template void f() {} void (*p)() = f<0>; template void f() {} void (*q)() = f<>; // Not perfect - this code in the dump would be ambiguous, but it's the best we // can do to differentiate these two implicit specializations. // CHECK1: template<> void f<0L>() // CHECK1: template<> void f<0U>() }