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