Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaTemplate / make_integer_seq.cpp
blob644bf41f8614c8a36a0b86bf405b7d67a7dfae09
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -triple x86_64-linux-gnu -ast-dump -verify -xc++ < %s | FileCheck %s
3 template <class A1, A1... A2> struct A {};
5 using test1 = __make_integer_seq<A, int, 1>;
6 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:5:1, col:43> col:7 test1 '__make_integer_seq<A, int, 1>':'A<int, 0>'
7 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar
8 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar alias __make_integer_seq
9 // CHECK-NEXT: |-TemplateArgument template A
10 // CHECK-NEXT: |-TemplateArgument type 'int'
11 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
12 // CHECK-NEXT: |-TemplateArgument expr
13 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int'
14 // CHECK-NEXT: | |-value: Int 1
15 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1
16 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>' sugar A
17 // CHECK-NEXT: |-TemplateArgument type 'int'
18 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
19 // CHECK-NEXT: |-TemplateArgument expr
20 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int'
21 // CHECK-NEXT: | |-value: Int 0
22 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 0
23 // CHECK-NEXT: `-RecordType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>'
24 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
26 template <class B1, B1 B2> using B = __make_integer_seq<A, B1, B2>;
27 using test2 = B<int, 1>;
28 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:27:1, col:23> col:7 test2 'B<int, 1>':'A<int, 0>'
29 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar
30 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar alias B
31 // CHECK-NEXT: |-TemplateArgument type 'int'
32 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
33 // CHECK-NEXT: |-TemplateArgument expr
34 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:22> 'int'
35 // CHECK-NEXT: | |-value: Int 1
36 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:22> 'int' 1
37 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar
38 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar alias __make_integer_seq
39 // CHECK-NEXT: |-TemplateArgument template A
40 // CHECK-NEXT: |-TemplateArgument type 'int'
41 // CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar class depth 0 index 0 B1
42 // CHECK-NEXT: | |-TypeAliasTemplate 0x{{[0-9A-Fa-f]+}} 'B'
43 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
44 // CHECK-NEXT: |-TemplateArgument expr
45 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <line:26:64> 'int'
46 // CHECK-NEXT: | |-value: Int 1
47 // CHECK-NEXT: | `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} <col:64> 'int'
48 // CHECK-NEXT: | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <col:21, col:24> col:24 referenced 'B1' depth 0 index 1 B2
49 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int' 1
50 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>' sugar A
51 // CHECK-NEXT: |-TemplateArgument type 'int'
52 // CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar class depth 0 index 0 B1
53 // CHECK-NEXT: | |-TypeAliasTemplate 0x{{[0-9A-Fa-f]+}} 'B'
54 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
55 // CHECK-NEXT: |-TemplateArgument expr
56 // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:64> 'int'
57 // CHECK-NEXT: | |-value: Int 0
58 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int' 0
59 // CHECK-NEXT: `-RecordType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>'
60 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
62 template <template <class T, T...> class S, class T, int N> struct C {
63 using test3 = __make_integer_seq<S, T, N>;
64 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:63:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<type-parameter-0-1, N>'
65 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' sugar dependent
66 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' sugar dependent alias __make_integer_seq
67 // CHECK-NEXT: |-TemplateArgument template S
68 // CHECK-NEXT: |-TemplateArgument type 'T'
69 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1
70 // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T'
71 // CHECK-NEXT: |-TemplateArgument expr
72 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'T' <Dependent>
73 // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
74 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<type-parameter-0-1, N>' dependent __make_integer_seq
75 // CHECK-NEXT: |-TemplateArgument template
76 // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-1'
77 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent depth 0 index 1
78 // CHECK-NEXT: `-TemplateArgument expr
79 // CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'T' <Dependent>
80 // CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
82 using test4 = __make_integer_seq<A, T, 1>;
83 // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:82:3, col:43> col:9 test4 '__make_integer_seq<A, T, 1>':'__make_integer_seq<A, type-parameter-0-1, 1>'
84 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' sugar dependent
85 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' sugar dependent alias __make_integer_seq
86 // CHECK-NEXT: |-TemplateArgument template A
87 // CHECK-NEXT: |-TemplateArgument type 'T'
88 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1
89 // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T'
90 // CHECK-NEXT: |-TemplateArgument expr
91 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'T' <Dependent>
92 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1
93 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, type-parameter-0-1, 1>' dependent __make_integer_seq
94 // CHECK-NEXT: |-TemplateArgument template A
95 // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-1'
96 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent depth 0 index 1
97 // CHECK-NEXT: `-TemplateArgument expr
98 // CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'T' <Dependent>
99 // CHECK-NEXT: `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1
101 using test5 = __make_integer_seq<A, int, N>;
102 // CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:101:3, col:45> col:9 test5 '__make_integer_seq<A, int, N>'
103 // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' sugar dependent
104 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' sugar dependent alias __make_integer_seq
105 // CHECK-NEXT: |-TemplateArgument template A
106 // CHECK-NEXT: |-TemplateArgument type 'int'
107 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
108 // CHECK-NEXT: |-TemplateArgument expr
109 // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
110 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' dependent __make_integer_seq
111 // CHECK-NEXT: |-TemplateArgument template A
112 // CHECK-NEXT: |-TemplateArgument type 'int'
113 // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
114 // CHECK-NEXT: `-TemplateArgument expr
115 // CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
118 // expected-no-diagnostics
120 template <class T, class S> struct D;
121 template <class T> struct D<T, __make_integer_seq<A, int, sizeof(T)>> {};
122 template struct D<char, A<int, 0>>;
124 template <class T, class S> struct E;
125 template <class T> struct E<T, __make_integer_seq<A, T, 2>> {};
126 template struct E<short, A<short, 0, 1>>;
128 template <template <class A1, A1... A2> class T, class S> struct F;
129 template <template <class A1, A1... A2> class T> struct F<T, __make_integer_seq<T, long, 3>> {};
130 template struct F<A, A<long, 0, 1, 2>>;
132 template <class T> struct G;
133 template <class T> struct G<__make_integer_seq<A, T, 1>> {};
134 template <class T> struct G<__make_integer_seq<A, T, 1U>> {};
136 template <int S, class = __make_integer_seq<A, int, S>> struct H;
137 template <int S, int... Is> struct H<S, A<int, Is...>> { };
139 template <int S> void h(H<S>);
140 void test_h() { h(H<5>{}); }