forked from OSchip/llvm-project
NFC: [clang] add template AST test for make_integer_seq and type_pack_element
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D133261
This commit is contained in:
parent
1b69ce1208
commit
591452eb23
|
@ -0,0 +1,103 @@
|
|||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -triple x86_64-linux-gnu -ast-dump -verify -xc++ < %s | FileCheck %s
|
||||
|
||||
template <class A1, A1... A2> struct A {};
|
||||
|
||||
using test1 = __make_integer_seq<A, int, 1>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:5:1, col:43> col:7 test1 '__make_integer_seq<A, int, 1>':'A<int, 0>'
|
||||
// CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar
|
||||
// CHECK-NEXT: | `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar __make_integer_seq
|
||||
// CHECK-NEXT: | |-TemplateArgument template A
|
||||
// CHECK-NEXT: | |-TemplateArgument type 'int'
|
||||
// CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
// CHECK-NEXT: | |-TemplateArgument expr
|
||||
// CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int'
|
||||
// CHECK-NEXT: | | |-value: Int 1
|
||||
// CHECK-NEXT: | | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1
|
||||
// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>'
|
||||
// CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
|
||||
|
||||
template <class B1, B1 B2> using B = __make_integer_seq<A, B1, B2>;
|
||||
using test2 = B<int, 1>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:20:1, col:23> col:7 test2 'B<int, 1>':'A<int, 0>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar alias B
|
||||
// CHECK-NEXT: |-TemplateArgument type 'int'
|
||||
// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:22> 'int'
|
||||
// CHECK-NEXT: | |-value: Int 1
|
||||
// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:22> 'int' 1
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar __make_integer_seq
|
||||
// CHECK-NEXT: |-TemplateArgument template A
|
||||
// CHECK-NEXT: |-TemplateArgument type 'int':'int'
|
||||
// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
|
||||
// CHECK-NEXT: | |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'B1' dependent depth 0 index 0
|
||||
// CHECK-NEXT: | | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'B1'
|
||||
// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <line:19:64> 'int'
|
||||
// CHECK-NEXT: | |-value: Int 1
|
||||
// CHECK-NEXT: | `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} <col:64> 'int'
|
||||
// CHECK-NEXT: | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <col:21, col:24> col:24 referenced 'B1' depth 0 index 1 B2
|
||||
// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int' 1
|
||||
// CHECK-NEXT: `-RecordType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>'
|
||||
// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
|
||||
|
||||
template <template <class T, T...> class S, class T, int N> struct C {
|
||||
using test3 = __make_integer_seq<S, T, N>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:48:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<S, T, N>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' dependent __make_integer_seq
|
||||
// CHECK-NEXT: |-TemplateArgument template S
|
||||
// CHECK-NEXT: |-TemplateArgument type 'T'
|
||||
// CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1
|
||||
// CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T'
|
||||
// CHECK-NEXT: `-TemplateArgument expr
|
||||
// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent>
|
||||
// CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
|
||||
|
||||
using test4 = __make_integer_seq<A, T, 1>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:60:3, col:43> col:9 test4 '__make_integer_seq<A, T, 1>':'__make_integer_seq<A, T, 1>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' dependent __make_integer_seq
|
||||
// CHECK-NEXT: |-TemplateArgument template A
|
||||
// CHECK-NEXT: |-TemplateArgument type 'T'
|
||||
// CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1
|
||||
// CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T'
|
||||
// CHECK-NEXT: `-TemplateArgument expr
|
||||
// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent>
|
||||
// CHECK-NEXT: `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1
|
||||
|
||||
using test5 = __make_integer_seq<A, int, N>;
|
||||
// CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:72:3, col:45> col:9 test5 '__make_integer_seq<A, int, N>':'__make_integer_seq<A, int, N>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' dependent __make_integer_seq
|
||||
// CHECK-NEXT: |-TemplateArgument template A
|
||||
// CHECK-NEXT: |-TemplateArgument type 'int'
|
||||
// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
// CHECK-NEXT: `-TemplateArgument expr
|
||||
// CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
|
||||
};
|
||||
|
||||
template <class T, class S> struct D; // expected-note {{template is declared here}}
|
||||
template <class T> struct D<T, __make_integer_seq<A, int, sizeof(T)>> {};
|
||||
template struct D<char, A<int, 0>>; // expected-error {{explicit instantiation of undefined template}}
|
||||
|
||||
template <class T, class S> struct E; // expected-note {{template is declared here}}
|
||||
template <class T> struct E<T, __make_integer_seq<A, T, 2>> {};
|
||||
template struct E<short, A<short, 0, 1>>; // expected-error {{explicit instantiation of undefined template}}
|
||||
|
||||
template <template <class A1, A1... A2> class T, class S> struct F; // expected-note {{template is declared here}}
|
||||
template <template <class A1, A1... A2> class T> struct F<T, __make_integer_seq<T, long, 3>> {};
|
||||
template struct F<A, A<long, 0, 1, 2>>; // expected-error {{explicit instantiation of undefined template}}
|
||||
|
||||
template <class T> struct G;
|
||||
template <class T> struct G<__make_integer_seq<A, T, 1>> {};
|
||||
template <class T> struct G<__make_integer_seq<A, T, 1U>> {};
|
||||
|
||||
template <int S, class = __make_integer_seq<A, int, S>> struct H;
|
||||
template <int S, int... Is> struct H<S, A<int, Is...>> { };
|
||||
|
||||
template <int S> void h(H<S>); // expected-note {{could not match '__make_integer_seq' against 'A'}}
|
||||
void test_h() { h(H<5>{}); } // expected-error {{no matching function for call to 'h'}}
|
|
@ -0,0 +1,68 @@
|
|||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -triple x86_64-linux-gnu -ast-dump -verify -xc++ < %s | FileCheck %s
|
||||
|
||||
using test1 = __type_pack_element<0, int>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <<stdin>:3:1, col:41> col:7 test1 '__type_pack_element<0, int>':'int'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar __type_pack_element
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:35> 'unsigned long'
|
||||
// CHECK-NEXT: | |-value: Int 0
|
||||
// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:35> 'unsigned long' <IntegralCast>
|
||||
// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:35> 'int' 0
|
||||
// CHECK-NEXT: |-TemplateArgument type 'int'
|
||||
// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
// CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
|
||||
template<int N, class ...Ts> struct A {
|
||||
using test2 = __type_pack_element<N, Ts...>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:17:3, col:45> col:9 test2 '__type_pack_element<N, Ts...>':'__type_pack_element<N, Ts...>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, Ts...>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, Ts...>' dependent __type_pack_element
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast>
|
||||
// CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
|
||||
// CHECK-NEXT: `-TemplateArgument type 'Ts...'
|
||||
// CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
|
||||
// CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
|
||||
// CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
|
||||
|
||||
using test3 = __type_pack_element<0, Ts...>;
|
||||
// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:29:3, col:45> col:9 test3 '__type_pack_element<0, Ts...>':'__type_pack_element<0, Ts...>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' dependent __type_pack_element
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long'
|
||||
// CHECK-NEXT: | |-value: Int 0
|
||||
// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast>
|
||||
// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:37> 'int' 0
|
||||
// CHECK-NEXT: `-TemplateArgument type 'Ts...'
|
||||
// CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
|
||||
// CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
|
||||
// CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
|
||||
|
||||
using test4 = __type_pack_element<N, int>;
|
||||
// CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:43:3, col:43> col:9 test4 '__type_pack_element<N, int>':'__type_pack_element<N, int>'
|
||||
// CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' sugar dependent
|
||||
// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' dependent __type_pack_element
|
||||
// CHECK-NEXT: |-TemplateArgument expr
|
||||
// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast>
|
||||
// CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
|
||||
// CHECK-NEXT: `-TemplateArgument type 'int'
|
||||
// CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
|
||||
};
|
||||
|
||||
template <class T, class S> struct B; // expected-note {{template is declared here}}
|
||||
template <class T> struct B<T, __type_pack_element<sizeof(T), void, long>> {};
|
||||
template struct B<char, long>; // expected-error {{explicit instantiation of undefined template}}
|
||||
|
||||
template <class T, class S> struct C; // expected-note {{template is declared here}}
|
||||
template <class T> struct C<T, __type_pack_element<0, T, short>> {};
|
||||
template struct C<int, int>; // expected-error {{explicit instantiation of undefined template}}
|
||||
|
||||
template <class T> struct D;
|
||||
template <class T, class U> struct D<__type_pack_element<0, T, U>> {};
|
||||
template <class T, class U> struct D<__type_pack_element<0, U, T>> {};
|
||||
|
||||
template <class T> struct E;
|
||||
template <class T> struct E<__type_pack_element<0, T>> {};
|
||||
template <class T, class U> struct E<__type_pack_element<0, T, U>> {};
|
Loading…
Reference in New Issue