blob: 4d04209e110b348c2a0629820568d8dec705ba45 [file] [log] [blame]
Aaron Ballman8c208282017-12-21 21:42:42 +00001// 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
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 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:
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 {{.*}} 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
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>();