56 lines · cpp
1// RUN: %clang_cc1 -std=c++14 -verify -ast-dump %s | FileCheck %s2// expected-no-diagnostics3 4// CHECK: FunctionDecl {{.*}} used func 'void ()'5// CHECK-NEXT: TemplateArgument type 'int'6// CHECK: LambdaExpr {{.*}} '(lambda at7// CHECK: ParmVarDecl {{.*}} used f 'foo' cinit8// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'9 10namespace PR28795 {11 template<typename T>12 void func() {13 enum class foo { a, b };14 auto bar = [](foo f = foo::a) { return f; };15 bar();16 }17 18 void foo() {19 func<int>();20 }21}22 23// CHECK: ClassTemplateSpecializationDecl {{.*}} struct class2 definition24// CHECK: TemplateArgument type 'int'25// CHECK: LambdaExpr {{.*}} '(lambda at26// CHECK: ParmVarDecl {{.*}} used f 'foo' cinit27// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'28 29// Template struct case:30template <class T> struct class2 {31 void bar() {32 enum class foo { a, b };33 [](foo f = foo::a) { return f; }();34 }35};36 37template struct class2<int>;38 39// CHECK: FunctionTemplateDecl {{.*}} f140// CHECK-NEXT: TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T41// CHECK-NEXT: FunctionDecl {{.*}} f1 'void ()'42// CHECK: FunctionDecl {{.*}} f1 'void ()'43// CHECK-NEXT: TemplateArgument type 'int'44// CHECK: ParmVarDecl {{.*}} n 'foo' cinit45// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'46 47template<typename T>48void f1() {49 enum class foo { a, b };50 struct S {51 int g1(foo n = foo::a);52 };53}54 55template void f1<int>();56