1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s
2 
3 // Test with serialization:
4 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown -emit-pch -o %t %s
5 // RUN: %clang_cc1 -x c++ -std=c++20 -triple x86_64-unknown-unknown -include-pch %t \
6 // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \
7 // RUN: | FileCheck --strict-whitespace %s
8 
9 template <typename T>
10 concept unary_concept = true;
11 
12 template <typename T, typename U>
13 concept binary_concept = true;
14 
15 template <typename... Ts>
16 concept variadic_concept = true;
17 
18 template <typename T>
19 struct Foo {
20   // CHECK:      TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
21   // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13, col:31> 'bool' Concept {{.*}} 'binary_concept'
22   // CHECK-NEXT:   |-TemplateArgument {{.*}} type 'R'
23   // CHECK-NEXT:   | `-TemplateTypeParmType {{.*}} 'R'
24   // CHECK-NEXT:   |   `-TemplateTypeParm {{.*}} 'R'
25   // CHECK-NEXT:   `-TemplateArgument {{.*}} type 'int'
26   // CHECK-NEXT:     `-BuiltinType {{.*}} 'int'
27   template <binary_concept<int> R>
28   Foo(R);
29 
30   // CHECK:      TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept'
31   // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13> 'bool'
32   template <unary_concept R>
33   Foo(R);
34 
35   // CHECK:      FunctionTemplateDecl {{.*}} <line:[[@LINE+1]]:3, line:[[@LINE+2]]:39> {{.*}} Foo<T>
36   template <typename R>
37   Foo(R, int) requires unary_concept<R>;
38 
39   // CHECK:      FunctionTemplateDecl {{.*}} <line:[[@LINE+1]]:3, line:[[@LINE+3]]:3> {{.*}} Foo<T>
40   template <typename R>
FooFoo41   Foo(R, char) requires unary_concept<R> {
42   }
43 
44   // CHECK: CXXFoldExpr {{.*}} <col:13, col:29>
45   template <variadic_concept... Ts>
46   Foo();
47 
48   // CHECK: CXXFoldExpr {{.*}} <col:13, col:34>
49   template <variadic_concept<int>... Ts>
50   Foo();
51 };
52