Debian Codegraph @

clang/test/SemaTemplate/type_pack_element.cpp

raw
1 // RUN: %clang_cc1 -std=c++23 -triple x86_64-linux-gnu -ast-dump -verify -xc++ < %s | FileCheck %s
2
3 using test1 = __type_pack_element<0, int>;
4 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <<stdin>:3:1, col:41> col:7 test1 '__type_pack_element<0, int>':'int'
5 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar alias
6 // CHECK-NEXT: |-name: '__type_pack_element' qualified
7 // CHECK-NEXT: | `-BuiltinTemplateDecl {{.+}} __type_pack_element
8 // CHECK-NEXT: |-TemplateArgument expr '0'
9 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:35> '__size_t':'unsigned long'
10 // CHECK-NEXT: | |-value: Int 0
11 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:35> '__size_t':'unsigned long' <IntegralCast>
12 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:35> 'int' 0
13 // CHECK-NEXT: |-TemplateArgument type 'int'
14 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
15 // CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
16
17 template<int N, class ...Ts> struct A {
18 using test2 = __type_pack_element<N, Ts...>;
19 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:3, col:45> col:9 test2 '__type_pack_element<N, Ts...>'
20 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, Ts...>' dependent
21 // CHECK-NEXT: |-name: '__type_pack_element' qualified
22 // CHECK-NEXT: | `-BuiltinTemplateDecl {{.+}} __type_pack_element
23 // CHECK-NEXT: |-TemplateArgument expr 'N'
24 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> '__size_t':'unsigned long' <IntegralCast>
25 // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
26 // CHECK-NEXT: `-TemplateArgument type 'Ts...'
27 // CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
28 // CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
29 // CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
30
31 using test3 = __type_pack_element<0, Ts...>;
32 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:3, col:45> col:9 test3 '__type_pack_element<0, Ts...>'
33 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' dependent
34 // CHECK-NEXT: |-name: '__type_pack_element' qualified
35 // CHECK-NEXT: | `-BuiltinTemplateDecl {{.+}} __type_pack_element
36 // CHECK-NEXT: |-TemplateArgument expr '0'
37 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:37> '__size_t':'unsigned long'
38 // CHECK-NEXT: | |-value: Int 0
39 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> '__size_t':'unsigned long' <IntegralCast>
40 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:37> 'int' 0
41 // CHECK-NEXT: `-TemplateArgument type 'Ts...'
42 // CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
43 // CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
44 // CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
45
46 using test4 = __type_pack_element<N, int>;
47 // CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:3, col:43> col:9 test4 '__type_pack_element<N, int>'
48 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' dependent
49 // CHECK-NEXT: |-name: '__type_pack_element' qualified
50 // CHECK-NEXT: | `-BuiltinTemplateDecl {{.+}} __type_pack_element
51 // CHECK-NEXT: |-TemplateArgument expr 'N'
52 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> '__size_t':'unsigned long' <IntegralCast>
53 // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
54 // CHECK-NEXT: `-TemplateArgument type 'int'
55 // CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
56 };
57
58 // expected-no-diagnostics
59
60 template <class T, class S> struct B;
61 template <class T> struct B<T, __type_pack_element<sizeof(T), void, long>> {};
62 template struct B<char, long>;
63
64 template <class T, class S> struct C;
65 template <class T> struct C<T, __type_pack_element<0, T, short>> {};
66 template struct C<int, int>;
67
68 template <class T> struct D;
69 template <class T, class U> struct D<__type_pack_element<0, T, U>> {};
70 template <class T, class U> struct D<__type_pack_element<0, U, T>> {};
71
72 template <class T> struct E;
73 template <class T> struct E<__type_pack_element<0, T>> {};
74 template <class T, class U> struct E<__type_pack_element<0, T, U>> {};