[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / default-expr-arguments-3.cpp
blob09fb7b290a1a15d34f85164f1a676d1bd677987d
1 // RUN: %clang_cc1 -std=c++14 -verify -ast-dump %s | FileCheck %s
2 // expected-no-diagnostics
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'
10 namespace 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();
18 void foo() {
19 func<int>();
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'
29 // Template struct case:
30 template <class T> struct class2 {
31 void bar() {
32 enum class foo { a, b };
33 [](foo f = foo::a) { return f; }();
37 template struct class2<int>;
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'
47 template<typename T>
48 void f1() {
49 enum class foo { a, b };
50 struct S {
51 int g1(foo n = foo::a);
55 template void f1<int>();