brintos

brintos / llvm-project-archived public Read only

0
0
Text · 47.7 KiB · 9e5756f Raw
984 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace2 3template<auto ...> struct X {};4template<template<typename X, X> typename> struct Y {};5template<typename ...> struct Z {};6 7template<typename T, typename ...Ts> struct A {8  template<Ts ...Ns, T *...Ps> A(X<Ps...>, Ts (*...qs)[Ns]);9};10int arr1[3], arr2[3];11short arr3[4];12A a(X<&arr1, &arr2>{}, &arr1, &arr2, &arr3);13using AT = decltype(a);14using AT = A<int[3], int, int, short>;15 16// CHECK-LABEL: Dumping <deduction guide for A>:17// CHECK: FunctionTemplateDecl18// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T19// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 ... Ts20// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'Ts...' depth 0 index 2 ... Ns21// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'T *' depth 0 index 3 ... Ps22// CHECK: |-CXXDeductionGuideDecl23// CHECK: | |-ParmVarDecl {{.*}} 'X<Ps...>'24// CHECK: | `-ParmVarDecl {{.*}} 'Ts (*)[Ns]...' pack25// CHECK: `-CXXDeductionGuideDecl26// CHECK:   |-TemplateArgument type 'int[3]'27// CHECK:   |-TemplateArgument pack28// CHECK:   | |-TemplateArgument type 'int'29// CHECK:   | |-TemplateArgument type 'int'30// CHECK:   | `-TemplateArgument type 'short'31// CHECK:   |-TemplateArgument pack32// CHECK:   | |-TemplateArgument integral '3'33// CHECK:   | |-TemplateArgument integral '3'34// CHECK:   | `-TemplateArgument integral '(short)4'35// CHECK:   |-TemplateArgument pack36// CHECK:   | |-TemplateArgument decl37// CHECK:   | | `-Var {{.*}} 'arr1' 'int[3]'38// CHECK:   | `-TemplateArgument decl39// CHECK:   |   `-Var {{.*}} 'arr2' 'int[3]'40// CHECK:   |-ParmVarDecl {{.*}} 'X<&arr1, &arr2>'41// CHECK:   |-ParmVarDecl {{.*}} 'int (*)[3]'42// CHECK:   |-ParmVarDecl {{.*}} 'int (*)[3]'43// CHECK:   `-ParmVarDecl {{.*}} 'short (*)[4]'44// CHECK: FunctionProtoType {{.*}} 'auto (X<Ps...>, Ts (*)[Ns]...) -> A<T, Ts...>' dependent trailing_return45// CHECK: |-InjectedClassNameType {{.*}} 'A<T, Ts...>' dependent46// CHECK: |-TemplateSpecializationType {{.*}} 'X<Ps...>' dependent47// CHECK: | `-TemplateArgument expr48// CHECK: |   `-PackExpansionExpr {{.*}} 'T *'49// CHECK: |     `-DeclRefExpr {{.*}} 'T *' NonTypeTemplateParm {{.*}} 'Ps' 'T *'50// CHECK: `-PackExpansionType {{.*}} 'Ts (*)[Ns]...' dependent51// CHECK:   `-PointerType {{.*}} 'Ts (*)[Ns]' dependent contains_unexpanded_pack52// CHECK:     `-ParenType {{.*}} 'Ts[Ns]' sugar dependent contains_unexpanded_pack53// CHECK:       `-DependentSizedArrayType {{.*}} 'Ts[Ns]' dependent contains_unexpanded_pack54// CHECK:         |-TemplateTypeParmType {{.*}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack55// CHECK:         | `-TemplateTypeParm {{.*}} 'Ts'56// CHECK:         `-DeclRefExpr {{.*}} 'Ts' NonTypeTemplateParm {{.*}} 'Ns' 'Ts...'57 58template<typename T, T V> struct B {59  template<typename U, U W> B(X<W, V>);60};61B b(X<nullptr, 'x'>{});62using BT = decltype(b);63using BT = B<char, 'x'>;64 65// CHECK-LABEL: Dumping <deduction guide for B>:66// CHECK: FunctionTemplateDecl67// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T68// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'T' depth 0 index 1 V69// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U70// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'U' depth 0 index 3 W71// CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (X<W, V>) -> B<T, V>'72// CHECK: | `-ParmVarDecl {{.*}} 'X<W, V>'73// CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (X<nullptr, 'x'>) -> B<char, 'x'>'74// CHECK:   |-TemplateArgument type 'char'75// CHECK:   |-TemplateArgument integral ''x''76// CHECK:   |-TemplateArgument type 'std::nullptr_t'77// CHECK:   |-TemplateArgument nullptr78// CHECK:   `-ParmVarDecl {{.*}} 'X<nullptr, 'x'>'79// CHECK: FunctionProtoType {{.*}} 'auto (X<W, V>) -> B<T, V>' dependent trailing_return80// CHECK: |-InjectedClassNameType {{.*}} 'B<T, V>' dependent81// CHECK: `-TemplateSpecializationType {{.*}} 'X<W, V>' dependent82// CHECK:   |-TemplateArgument expr83// CHECK:   | `-DeclRefExpr {{.*}} 'U' NonTypeTemplateParm {{.*}} 'W' 'U'84// CHECK:   `-TemplateArgument expr85// CHECK:     `-DeclRefExpr {{.*}} 'T' NonTypeTemplateParm {{.*}} 'V' 'T'86 87template<typename A> struct C {88  template<template<typename X, X> typename T, typename U, U V = 0> C(A, Y<T>, U);89};90C c(1, Y<B>{}, 2);91using CT = decltype(c);92using CT = C<int>;93 94// CHECK-LABEL: Dumping <deduction guide for C>:95// CHECK: FunctionTemplateDecl96// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 A97// CHECK: |-TemplateTemplateParmDecl {{.*}} depth 0 index 1 T98// CHECK: | |-TemplateTypeParmDecl {{.*}} typename depth 1 index 0 X99// CHECK: | `-NonTypeTemplateParmDecl {{.*}} 'X' depth 1 index 1100// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U101// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'U' depth 0 index 3 V102// CHECK: | `-TemplateArgument {{.*}} expr103// CHECK: |   `-IntegerLiteral {{.*}} 'int' 0104// CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (A, Y<T>, U) -> C<A>'105// CHECK: | |-ParmVarDecl {{.*}} 'A'106// CHECK: | |-ParmVarDecl {{.*}} 'Y<T>'107// CHECK: | `-ParmVarDecl {{.*}} 'U'108// CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (int, Y<B>, int) -> C<int>'109// CHECK:  |-TemplateArgument type 'int'110// CHECK:  |-TemplateArgument template 'B'111// CHECK:  |-TemplateArgument type 'int'112// CHECK:  |-TemplateArgument integral '0'113// CHECK:  |-ParmVarDecl {{.*}} 'int'114// CHECK:  |-ParmVarDecl {{.*}} 'Y<B>'115// CHECK:  `-ParmVarDecl {{.*}} 'int'116// CHECK: FunctionProtoType {{.*}} 'auto (A, Y<T>, U) -> C<A>' dependent trailing_return cdecl117// CHECK: |-InjectedClassNameType {{.*}} 'C<A>' dependent118// CHECK: |-TemplateTypeParmType {{.*}} 'A' dependent depth 0 index 0119// CHECK: | `-TemplateTypeParm {{.*}} 'A'120// CHECK: |-TemplateSpecializationType {{.*}} 'Y<T>' dependent121// CHECK: | `-TemplateArgument template122// CHECK: `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 2123 124template<typename ...T> struct D { // expected-note {{candidate}} \125                                   // expected-note {{implicit deduction guide declared as 'template <typename ...T> D(D<T...>) -> D<T...>'}}126  template<typename... U> using B = int(int (*...p)(T, U));127  template<typename U1, typename U2> D(B<U1, U2>*); // expected-note {{candidate}} \128                                                    // expected-note {{implicit deduction guide declared as 'template <typename ...T, typename U1, typename U2> D(B<U1, U2> *) -> D<T...>'}}129};130int f(int(int, int), int(int, int));131// FIXME: We can't deduce this because we can't deduce through a132// SubstTemplateTypeParmPackType.133D d = f; // expected-error {{no viable}}134using DT = decltype(d);135using DT = D<int, int>;136 137// CHECK-LABEL: Dumping <deduction guide for D>:138// CHECK: FunctionTemplateDecl139// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 ... T140// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 U1141// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U2142// CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (B<U1, U2> *) -> D<T...>'143// CHECK:   `-ParmVarDecl {{.*}} 'B<U1, U2> *'144// CHECK: FunctionProtoType {{.*}} 'auto (B<U1, U2> *) -> D<T...>' dependent trailing_return145// CHECK: |-InjectedClassNameType {{.*}} 'D<T...>' dependent146// CHECK: `-PointerType {{.*}} 'B<U1, U2> *' dependent147// CHECK:   `-TemplateSpecializationType {{.*}} 'B<U1, U2>' sugar dependent alias148// CHECK:     |-TemplateArgument type 'U1'149// CHECK:     |-TemplateArgument type 'U2'150// CHECK:     `-FunctionProtoType {{.*}} 'int (int (*)(T, U)...)' dependent cdecl151// CHECK:       |-BuiltinType {{.*}} 'int'152// CHECK:       `-PackExpansionType {{.*}} 'int (*)(T, U)...' dependent expansions 2153// CHECK:         `-PointerType {{.*}} 'int (*)(T, U)' dependent contains_unexpanded_pack154// CHECK:           `-ParenType {{.*}} 'int (T, U)' sugar dependent contains_unexpanded_pack155// CHECK:             `-FunctionProtoType {{.*}} 'int (T, U)' dependent contains_unexpanded_pack cdecl156// CHECK:               |-BuiltinType {{.*}} 'int'157// CHECK:               |-TemplateTypeParmType {{.*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack158// CHECK:               | `-TemplateTypeParm {{.*}} 'T'159// CHECK:               `-SubstTemplateTypeParmPackType {{.*}} 'U' dependent contains_unexpanded_pack typename depth 1 index 0 ... U160// CHECK:                 |-TypeAliasTemplate {{.*}} 'B'161// CHECK:                 `-TemplateArgument pack162// CHECK:                   |-TemplateArgument type 'U1':'type-parameter-0-1'163// CHECK-NOT: Subst164// CHECK:                   | `-TemplateTypeParmType165// CHECK:                   `-TemplateArgument type 'U2':'type-parameter-0-2'166// CHECK-NOT: Subst167// CHECK:                     `-TemplateTypeParmType168 169template<int ...N> struct E { // expected-note {{candidate}} \170                                 expected-note {{implicit deduction guide declared as 'template <int ...N> E(E<N...>) -> E<N...>'}}171  template<int ...M> using B = Z<X<N, M>...>;172  template<int M1, int M2> E(B<M1, M2>); // expected-note {{candidate}} \173                                         // expected-note {{implicit deduction guide declared as 'template <int ...N, int M1, int M2> E(B<M1, M2>) -> E<N...>'}}}}174};175// FIXME: We can't deduce this because we can't deduce through a176// SubstNonTypeTemplateParmPackExpr.177E e = Z<X<1, 2>, X<3, 4>>(); // expected-error {{no viable}}178using ET = decltype(e);179using ET = E<1, 3>;180 181// CHECK-LABEL: Dumping <deduction guide for E>:182// CHECK: FunctionTemplateDecl183// CHECK: |-NonTypeTemplateParmDecl [[N:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 0 ... N184// CHECK: |-NonTypeTemplateParmDecl [[M1:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 1 M1185// CHECK: |-NonTypeTemplateParmDecl [[M2:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 2 M2186// CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (B<M1, M2>) -> E<N...>'187// CHECK:   `-ParmVarDecl {{.*}} 'B<M1, M2>':'Z<X<N, M>...>'188// CHECK: FunctionProtoType {{.*}} 'auto (B<M1, M2>) -> E<N...>' dependent trailing_return189// CHECK: |-InjectedClassNameType {{.*}} 'E<N...>' dependent190// CHECK: `-TemplateSpecializationType {{.*}} 'B<M1, M2>' sugar dependent alias191// CHECK:   |-TemplateArgument expr192// CHECK:   | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'M1' 'int'193// CHECK:   |-TemplateArgument expr194// CHECK:   | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'M2' 'int'195// CHECK:   `-TemplateSpecializationType {{.*}} 'Z<X<N, M>...>' dependent196// CHECK:     `-TemplateArgument type 'X<N, M>...'197// CHECK:       `-PackExpansionType {{.*}} 'X<N, M>...' dependent expansions 2198// CHECK:         `-TemplateSpecializationType {{.*}} 'X<N, M>' dependent contains_unexpanded_pack199// CHECK:           |-TemplateArgument expr200// CHECK-NOT: Subst201// CHECK:           | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[N]] 'N' 'int'202// CHECK:           `-TemplateArgument expr203// CHECK:             `-SubstNonTypeTemplateParmPackExpr {{.*}} 'int'204// CHECK:               |-NonTypeTemplateParmDecl {{.*}} referenced 'int' depth 1 index 0 ... M205// CHECK:               `-TemplateArgument pack206// CHECK:                 |-TemplateArgument expr207// CHECK-NOT: Subst208// CHECK:                 | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[M1]] 'M1' 'int'209// CHECK:                 `-TemplateArgument expr210// CHECK-NOT: Subst211// CHECK:                   `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[M2]] 'M2' 'int'212 213template <char = 'x'> struct F;214 215template <char> struct F {216  template <typename U>217  requires(false) F(U);218  template <typename U>219  requires(true) F(U);220};221 222F s(0);223 224// CHECK-LABEL: Dumping <deduction guide for F>:225// CHECK: FunctionTemplateDecl226// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'char' depth 0 index 0227// CHECK:   `-TemplateArgument {{.*}} expr228// CHECK: |   |-inherited from NonTypeTemplateParm {{.*}} depth 0 index 0 'char'229// CHECK: |   `-CharacterLiteral {{.*}} 'char' 120230// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 U231// CHECK: |-ParenExpr {{.*}} 'bool'232// CHECK: | `-CXXBoolLiteralExpr {{.*}} 'bool' false233// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (U) -> F<value-parameter-0-0>'234// CHECK: | `-ParmVarDecl {{.*}} 'U'235// CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for F> 'auto (int) -> F<>'236// CHECK:   |-TemplateArgument integral ''x''237// CHECK:   |-TemplateArgument type 'int'238// CHECK:   | `-BuiltinType {{.*}} 'int'239// CHECK:   `-ParmVarDecl {{.*}} 'int'240// CHECK: FunctionProtoType {{.*}} 'auto (U) -> F<value-parameter-0-0>' dependent trailing_return cdecl241// CHECK: |-InjectedClassNameType {{.*}} 'F<value-parameter-0-0>' dependent242// CHECK: | `-CXXRecord {{.*}} 'F'243// CHECK: `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 1244 245template<typename T>246struct G { T t; };247 248G g = {1};249// CHECK-LABEL: Dumping <deduction guide for G>:250// CHECK: FunctionTemplateDecl251// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for G> 'auto (T) -> G<T>' aggregate252// CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for G> 'auto (int) -> G<int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate253 254template<typename X>255using AG = G<X>;256AG ag = {1};257// Verify that the aggregate deduction guide for alias templates is built.258// CHECK-LABEL: Dumping <deduction guide for AG>259// CHECK: FunctionTemplateDecl260// CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (X) -> G<X>'261// CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' implicit_instantiation262// CHECK:   |-TemplateArgument type 'int'263// CHECK:   | `-BuiltinType {{.*}} 'int'264// CHECK:   `-ParmVarDecl {{.*}} 'int'265 266template <typename X = int>267using BG = G<int>;268BG bg(1.0);269// CHECK-LABEL: Dumping <deduction guide for BG>270// CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for BG>271// CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' aggregate272 273template <typename D>274requires (sizeof(D) == 4)275struct Foo {276  Foo(D);277};278 279template <typename U>280using AFoo = Foo<G<U>>;281// Verify that the require-clause from the Foo deduction guide is transformed.282// The D occurrence should be rewritten to G<U>.283//284// CHECK-LABEL: Dumping <deduction guide for AFoo>285// CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for AFoo>286// CHECK-NEXT: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 U287// CHECK-NEXT: |-BinaryOperator {{.*}} '&&'288// CHECK-NEXT: | |-ParenExpr {{.*}} 'bool'289// CHECK-NEXT: | | `-BinaryOperator {{.*}} 'bool' '=='290// CHECK-NEXT: | |   |-UnaryExprOrTypeTraitExpr {{.*}} 'G<U>'291// CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}}292// CHECK-NEXT: | |     `-IntegerLiteral {{.*}}293// CHECK-NEXT: | `-TypeTraitExpr {{.*}} 'bool' __is_deducible294// CHECK-NEXT: |   |-DeducedTemplateSpecializationType {{.*}} 'AFoo' dependent295// CHECK-NEXT: |   | `-name: 'AFoo'296// CHECK-NEXT: |   |   `-TypeAliasTemplateDecl {{.+}} AFoo297// CHECK-NEXT: |   `-TemplateSpecializationType {{.*}} 'Foo<G<U>>' dependent298// CHECK:      |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for AFoo> 'auto (G<U>) -> Foo<G<U>>'299// CHECK-NEXT: | `-ParmVarDecl {{.*}} 'G<U>'300// CHECK-NEXT: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for AFoo> 'auto (G<int>) -> Foo<G<int>>' implicit_instantiation301// CHECK-NEXT:   |-TemplateArgument type 'int'302// CHECK-NEXT:   | `-BuiltinType {{.*}} 'int'303// CHECK-NEXT:   `-ParmVarDecl {{.*}} 'G<int>'304 305AFoo aa(G<int>{});306 307namespace TTP {308  template<typename> struct A {};309 310  template<class T> struct B {311    template<template <class> typename TT> B(TT<T>);312  };313 314  B b(A<int>{});315} // namespace TTP316 317// CHECK-LABEL: Dumping TTP::<deduction guide for B>:318// CHECK-NEXT:  FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[# @LINE - 7]]:5, col:51>319// CHECK-NEXT:  |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 T{{$}}320// CHECK-NEXT:  |-TemplateTemplateParmDecl {{.+}} depth 0 index 1 TT{{$}}321// CHECK-NEXT:  | `-TemplateTypeParmDecl {{.+}} class depth 1 index 0{{$}}322// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} 'auto (TT<T>) -> TTP::B<T>'{{$}}323// CHECK-NEXT:  | `-ParmVarDecl {{.+}} 'TT<T>'{{$}}324// CHECK-NEXT:  `-CXXDeductionGuideDecl {{.+}} 'auto (TTP::A<int>) -> TTP::B<int>'325// CHECK-NEXT:    |-TemplateArgument type 'int'326// CHECK-NEXT:    | `-BuiltinType {{.+}} 'int'{{$}}327// CHECK-NEXT:    |-TemplateArgument template 'TTP::A'{{$}}328// CHECK-NEXT:    | `-ClassTemplateDecl {{.+}} A{{$}}329// CHECK-NEXT:    `-ParmVarDecl {{.+}} 'TTP::A<int>'{{$}}330// CHECK-NEXT:  FunctionProtoType {{.+}} 'auto (TT<T>) -> TTP::B<T>' dependent trailing_return cdecl{{$}}331// CHECK-NEXT:  |-InjectedClassNameType {{.+}} 'TTP::B<T>' dependent{{$}}332// CHECK-NEXT:  | `-CXXRecord {{.+}} 'B'{{$}}333// CHECK-NEXT:  `-TemplateSpecializationType {{.+}} 'TT<T>' dependent{{$}}334// CHECK-NEXT:    |-name: 'TT':'template-parameter-0-1'335// CHECK-NEXT:    | `-TemplateTemplateParmDecl {{.+}} depth 0 index 1336// CHECK-NEXT:    `-TemplateArgument type 'T':'type-parameter-0-0'{{$}}337// CHECK-NEXT:      `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0{{$}}338// CHECK-NEXT:        `-TemplateTypeParm {{.+}} 'T'{{$}}339 340namespace GH64625 {341 342template <class T> struct X {343  T t[2];344};345 346X x = {{1, 2}};347 348// CHECK-LABEL: Dumping GH64625::<deduction guide for X>:349// CHECK-NEXT: FunctionTemplateDecl {{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:27> col:27 implicit <deduction guide for X>350// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:11, col:17> col:17 referenced class depth 0 index 0 T351// CHECK:      |-CXXDeductionGuideDecl {{.+}} <col:27> col:27 implicit <deduction guide for X> 'auto (T (&&)[2]) -> GH64625::X<T>' aggregate352// CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:27> col:27 'T (&&)[2]'353// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:27> col:27 implicit used <deduction guide for X> 'auto (int (&&)[2]) -> GH64625::X<int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate354// CHECK-NEXT:  |-TemplateArgument type 'int'355// CHECK-NEXT:  | `-BuiltinType {{.+}} 'int'356// CHECK-NEXT:  `-ParmVarDecl {{.+}} <col:27> col:27 'int (&&)[2]'357// CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2]) -> GH64625::X<T>' dependent trailing_return358// CHECK-NEXT: |-InjectedClassNameType {{.+}} 'GH64625::X<T>' dependent359// CHECK-NEXT: | `-CXXRecord {{.+}} 'X'360// CHECK-NEXT: `-RValueReferenceType {{.+}} 'T (&&)[2]' dependent361// CHECK-NEXT:  `-ConstantArrayType {{.+}} 'T[2]' dependent 2362// CHECK-NEXT:    `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0363// CHECK-NEXT:      `-TemplateTypeParm {{.+}} 'T'364 365template <class T, class U> struct TwoArrays {366  T t[2];367  U u[3];368};369 370TwoArrays ta = {{1, 2}, {3, 4, 5}};371// CHECK-LABEL: Dumping GH64625::<deduction guide for TwoArrays>:372// CHECK-NEXT: FunctionTemplateDecl {{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:36> col:36 implicit <deduction guide for TwoArrays>373// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:11, col:17> col:17 referenced class depth 0 index 0 T374// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:20, col:26> col:26 referenced class depth 0 index 1 U375// CHECK:      |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T (&&)[2], U (&&)[3]) -> GH64625::TwoArrays<T, U>' aggregate376// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T (&&)[2]'377// CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U (&&)[3]'378// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit used <deduction guide for TwoArrays> 'auto (int (&&)[2], int (&&)[3]) -> GH64625::TwoArrays<int, int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate379// CHECK-NEXT:   |-TemplateArgument type 'int'380// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'381// CHECK-NEXT:   |-TemplateArgument type 'int'382// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'383// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[2]'384// CHECK-NEXT:   `-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[3]'385// CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2], U (&&)[3]) -> GH64625::TwoArrays<T, U>' dependent trailing_return386// CHECK-NEXT: |-InjectedClassNameType {{.+}} 'GH64625::TwoArrays<T, U>' dependent387// CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays'388// CHECK-NEXT: |-RValueReferenceType {{.+}} 'T (&&)[2]' dependent389// CHECK-NEXT: | `-ConstantArrayType {{.+}} 'T[2]' dependent 2390// CHECK-NEXT: |   `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0391// CHECK-NEXT: |     `-TemplateTypeParm {{.+}} 'T'392// CHECK-NEXT: `-RValueReferenceType {{.+}} 'U (&&)[3]' dependent393// CHECK-NEXT:   `-ConstantArrayType {{.+}} 'U[3]' dependent 3394// CHECK-NEXT:     `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1395// CHECK-NEXT:       `-TemplateTypeParm {{.+}} 'U'396 397TwoArrays tb = {1, 2, {3, 4, 5}};398// CHECK:   |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T, T, U (&&)[3]) -> GH64625::TwoArrays<T, U>' aggregate399// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T'400// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T'401// CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U (&&)[3]'402// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit used <deduction guide for TwoArrays> 'auto (int, int, int (&&)[3]) -> GH64625::TwoArrays<int, int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate403// CHECK-NEXT:   |-TemplateArgument type 'int'404// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'405// CHECK-NEXT:   |-TemplateArgument type 'int'406// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'407// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int'408// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int'409// CHECK-NEXT:   `-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[3]'410// CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T, T, U (&&)[3]) -> GH64625::TwoArrays<T, U>' dependent trailing_return411// CHECK-NEXT: |-InjectedClassNameType {{.+}} 'GH64625::TwoArrays<T, U>' dependent412// CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays'413// CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0414// CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T'415// CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0416// CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T'417// CHECK-NEXT: `-RValueReferenceType {{.+}} 'U (&&)[3]' dependent418// CHECK-NEXT:   `-ConstantArrayType {{.+}} 'U[3]' dependent 3419// CHECK-NEXT:     `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1420// CHECK-NEXT:       `-TemplateTypeParm {{.+}} 'U'421 422TwoArrays tc = {{1, 2}, 3, 4, 5};423// CHECK: |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T (&&)[2], U, U, U) -> GH64625::TwoArrays<T, U>' aggregate424// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T (&&)[2]'425// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'U'426// CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'U'427// CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U'428// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit used <deduction guide for TwoArrays> 'auto (int (&&)[2], int, int, int) -> GH64625::TwoArrays<int, int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate429// CHECK-NEXT:   |-TemplateArgument type 'int'430// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'431// CHECK-NEXT:   |-TemplateArgument type 'int'432// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'433// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[2]'434// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int'435// CHECK-NEXT:   |-ParmVarDecl {{.+}} <col:36> col:36 'int'436// CHECK-NEXT:   `-ParmVarDecl {{.+}} <col:36> col:36 'int'437// CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2], U, U, U) -> GH64625::TwoArrays<T, U>' dependent trailing_return438// CHECK-NEXT: |-InjectedClassNameType {{.+}} 'GH64625::TwoArrays<T, U>' dependent439// CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays'440// CHECK-NEXT: |-RValueReferenceType {{.+}} 'T (&&)[2]' dependent441// CHECK-NEXT: | `-ConstantArrayType {{.+}} 'T[2]' dependent 2442// CHECK-NEXT: |   `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0443// CHECK-NEXT: |     `-TemplateTypeParm {{.+}} 'T'444// CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1445// CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'U'446// CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1447// CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'U'448// CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1449// CHECK-NEXT:   `-TemplateTypeParm {{.+}} 'U'450 451} // namespace GH64625452 453namespace GH83368 {454 455template <int N> struct A {456  int f1[N];457};458 459A a{.f1 = {1}};460 461// CHECK-LABEL: Dumping GH83368::<deduction guide for A>:462// CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:25> col:25 implicit <deduction guide for A>463// CHECK-NEXT: |-NonTypeTemplateParmDecl {{.+}} <col:11, col:15> col:15 referenced 'int' depth 0 index 0 N464// CHECK:      |-CXXDeductionGuideDecl {{.+}} <col:25> col:25 implicit <deduction guide for A> 'auto (int (&&)[N]) -> GH83368::A<N>' aggregate465// CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:25> col:25 'int (&&)[N]'466// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:25> col:25 implicit used <deduction guide for A> 'auto (int (&&)[1]) -> GH83368::A<1>' implicit_instantiation instantiated_from 0x{{.+}} aggregate467// CHECK-NEXT:   |-TemplateArgument integral '1'468// CHECK-NEXT:   `-ParmVarDecl {{.+}} <col:25> col:25 'int (&&)[1]'469// CHECK-NEXT: FunctionProtoType {{.+}} 'auto (int (&&)[N]) -> GH83368::A<N>' dependent trailing_return470// CHECK-NEXT: |-InjectedClassNameType {{.+}} 'GH83368::A<N>' dependent471// CHECK-NEXT: | `-CXXRecord {{.+}} 'A'472// CHECK-NEXT: `-RValueReferenceType {{.+}} 'int (&&)[N]' dependent473// CHECK-NEXT:   `-DependentSizedArrayType {{.+}} 'int[N]' dependent474// CHECK-NEXT:     |-BuiltinType {{.+}} 'int'475// CHECK-NEXT:     `-DeclRefExpr {{.+}} <{{.+}}:10> 'int' NonTypeTemplateParm {{.+}} 'N' 'int'476 477} // namespace GH83368478 479namespace GH60777 {480 481template <typename... Ts> constexpr bool True() { return true; }482 483template <typename T>484  requires(sizeof(T) > 1)485struct A {486  template <typename... Ts>487    requires(sizeof...(Ts) == 0)488  A(T val, Ts... tail)489    requires(True<Ts...>())490  {}491};492 493A a(42);494 495// `requires (sizeof(T) > 1)` goes into the deduction guide together with496// `requires (True<Ts...>())`, while `requires(sizeof...(Ts) == 0)` goes into497// the template parameter list of the synthesized declaration.498 499// CHECK-LABEL: Dumping GH60777::<deduction guide for A>:500// CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> {{.+}} implicit <deduction guide for A>501// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:20 referenced typename depth 0 index 0 T502// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:25 typename depth 0 index 1 ... Ts503// CHECK-NEXT: |-ParenExpr 0x{{.+}} <{{.+}}> 'bool'504// CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '=='505// CHECK-NEXT: |   |-SizeOfPackExpr {{.+}} Ts506// CHECK-NEXT: |   | `-TemplateArgument type 'Ts...':'type-parameter-0-1...'507// CHECK-NEXT: |   |   `-PackExpansionType 0x{{.+}} 'Ts...' dependent508// CHECK-NEXT: |   |     `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack509// CHECK-NEXT: |   |       `-TemplateTypeParm 0x{{.+}} 'Ts'510// CHECK-NEXT: |   `-ImplicitCastExpr {{.+}} <IntegralCast>511// CHECK-NEXT: |     `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 0512// CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> line:{{.+}} implicit <deduction guide for A> 'auto (T, Ts...) -> GH60777::A<T>'513// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} val 'T'514// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} tail 'Ts...' pack515// CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '&&'516// CHECK-NEXT: |   |-ParenExpr 0x{{.+}} <{{.+}}> 'bool'517// CHECK-NEXT: |   | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '>'518// CHECK-NEXT: |   |   |-UnaryExprOrTypeTraitExpr {{.+}} sizeof 'T'519// CHECK-NEXT: |   |   `-ImplicitCastExpr {{.+}} <IntegralCast>520// CHECK-NEXT: |   |     `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 1521// CHECK-NEXT: |   `-ParenExpr 0x{{.+}} <{{.+}}> '<dependent type>'522// CHECK-NEXT: |     `-CallExpr 0x{{.+}} <{{.+}}> '<dependent type>'523// CHECK-NEXT: |       `-UnresolvedLookupExpr 0x{{.+}} <col:14, col:24> '<dependent type>' {{.+}}524// CHECK-NEXT: |         `-TemplateArgument type 'Ts...':'type-parameter-0-1...'525// CHECK-NEXT: |           `-PackExpansionType 0x{{.+}} 'Ts...' dependent526// CHECK-NEXT: |             `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack527// CHECK-NEXT: |               `-TemplateTypeParm 0x{{.+}} 'Ts'528 529template <typename T>530struct B {531  template <typename... Ts>532  B(T val, Ts... tail)533    requires(True<tail...>())534  {}535};536 537B b(42, 43);538// expected-error@-1 {{no viable constructor}} \539//   expected-note@-6 {{constraints not satisfied}} \540//   expected-note@-5 {{because substituted constraint expression is ill-formed}} \541//   expected-note@-6 {{implicit deduction guide declared as 'template <typename T, typename ...Ts> B(T val, Ts ...tail) -> GH60777::B<T> requires (True<tail...>())'}} \542//   expected-note@-8 {{function template not viable}} \543//   expected-note@-8 {{implicit deduction guide declared as 'template <typename T> B(GH60777::B<T>) -> GH60777::B<T>'}}544 545} // namespace GH60777546 547// Examples from @hokein.548namespace GH98592 {549 550template <class T> concept True = true;551double arr3[3];552 553template <class T>554struct X {555  const int size;556  template <class U>557  constexpr X(T, U(&)[3]) requires True<T> : size(sizeof(T)) {}558};559 560template <typename T, typename U>561X(T, U (&)[3]) -> X<U>;562 563constexpr X x(3, arr3);564 565// The synthesized deduction guide is more constrained than the explicit one.566static_assert(x.size == 4);567 568// CHECK-LABEL: Dumping GH98592::<deduction guide for X>:569// CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for X>570// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:17 referenced class depth 0 index 0 T571// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:19 class depth 0 index 1 U572// CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for X> 'auto (T, U (&)[3]) -> GH98592::X<T>'573// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:15> col:16 'T'574// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'U (&)[3]'575// CHECK-NEXT: | `-ConceptSpecializationExpr 0x{{.+}} <col:36, col:42> 'bool' Concept 0x{{.+}} 'True'576// CHECK-NEXT: |   |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28577// CHECK-NEXT: |   | `-TemplateArgument type 'T'578// CHECK-NEXT: |   |   `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0579// CHECK-NEXT: |   |     `-TemplateTypeParm 0x{{.+}} 'T'580// CHECK-NEXT: |   `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0'581// CHECK-NEXT: |     `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0582// CHECK-NEXT: |       `-TemplateTypeParm 0x{{.+}} 'T'583// CHECK-NEXT: `-CXXDeductionGuideDecl 0x{{.+}} <col:3, col:63> col:13 implicit used <deduction guide for X> 'auto (int, double (&)[3]) -> GH98592::X<int>' implicit_instantiation584// CHECK-NEXT:   |-TemplateArgument type 'int'585// CHECK-NEXT:   | `-BuiltinType 0x{{.+}} 'int'586// CHECK-NEXT:   |-TemplateArgument type 'double'587// CHECK-NEXT:   | `-BuiltinType 0x{{.+}} 'double'588// CHECK-NEXT:   |-ParmVarDecl 0x{{.+}} <col:15> col:16 'int'589// CHECK-NEXT:   |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'double (&)[3]'590// CHECK-NEXT:   `-ConceptSpecializationExpr 0x{{.+}} <col:36, col:42> 'bool' Concept 0x{{.+}} 'True'591// CHECK-NEXT:     |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28592// CHECK-NEXT:     | `-TemplateArgument type 'T'593// CHECK-NEXT:     |   `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0594// CHECK-NEXT:     |     `-TemplateTypeParm 0x{{.+}} 'T'595// CHECK-NEXT:     `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0'596// CHECK-NEXT:       `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0597// CHECK-NEXT:         `-TemplateTypeParm 0x{{.+}} 'T'598 599template <class T> requires True<T> struct Y {600  const int size;601  template <class U>602  constexpr Y(T, U(&)[3]) : size(sizeof(T)) {}603};604 605template <typename T, typename U> Y(T, U (&)[3]) -> Y<U>;606 607constexpr Y y(3, arr3);608 609// Likewise, the synthesized deduction guide should be preferred610// according to [over.match.class.deduct]p1.611static_assert(y.size == 4);612 613// Dumping GH98592::<deduction guide for Y>:614// FunctionTemplateDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for Y>615// |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:17 referenced class depth 0 index 0 T616// |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:19 class depth 0 index 1 U617// |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for Y> 'auto (T, U (&)[3]) -> Y<T>'618// | |-ParmVarDecl 0x{{.+}} <col:15> col:16 'T'619// | |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'U (&)[3]'620// | `-ConceptSpecializationExpr 0x{{.+}} <{{.+}}> 'bool' Concept 0x{{.+}} 'True'621// |   |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28622// |   | `-TemplateArgument type 'type-parameter-0-0'623// |   |   `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0624// |   `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0'625// |     `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0626// |       `-TemplateTypeParm 0x{{.+}} 'T'627// `-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit used <deduction guide for Y> 'auto (int, double (&)[3]) -> GH98592::Y<int>' implicit_instantiation628//   |-TemplateArgument type 'int'629//   | `-BuiltinType 0x{{.+}} 'int'630//   |-TemplateArgument type 'double'631//   | `-BuiltinType 0x{{.+}} 'double'632//   |-ParmVarDecl 0x{{.+}} <col:15> col:16 'int'633//   |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'double (&)[3]'634//   `-ConceptSpecializationExpr 0x{{.+}} <{{.+}}> 'bool' Concept 0x{{.+}} 'True'635//     |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28636//     | `-TemplateArgument type 'type-parameter-0-0'637//     |   `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0638//     `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0'639//       `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0640//         `-TemplateTypeParm 0x{{.+}} 'T'641 642} // namespce GH98592643 644namespace GH122134 {645 646template <class, class>647concept Constraint = true;648 649template <class T, int> struct Struct {650  Struct(Constraint<T> auto) {}651};652 653template <int N = 0> using Test = Struct<int, N>;654 655Test test(42);656 657// CHECK-LABEL: Dumping GH122134::<deduction guide for Test>:658// CHECK-NEXT: FunctionTemplateDecl {{.*}} implicit <deduction guide for Test>659// CHECK-NEXT: |-NonTypeTemplateParmDecl {{.*}} 'int' depth 0 index 0 N660// CHECK-NEXT: | `-TemplateArgument {{.*}} expr '0'661// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 'int' 0662// CHECK-NEXT: |-TemplateTypeParmDecl {{.*}} Concept {{.*}} 'Constraint' depth 0 index 1 auto:1663// CHECK-NEXT: | `-ConceptSpecializationExpr {{.*}} 'bool' Concept {{.*}} 'Constraint'664// CHECK-NEXT: |   |-ImplicitConceptSpecializationDecl {{.*}}665// CHECK-NEXT: |   | |-TemplateArgument type 'auto:1'666// CHECK-NEXT: |   | | `-TemplateTypeParmType {{.*}} 'auto:1' dependent depth 0 index 1667// CHECK-NEXT: |   | |   `-TemplateTypeParm {{.*}} 'auto:1'668// CHECK-NEXT: |   | `-TemplateArgument type 'int'669// CHECK-NEXT: |   |   `-BuiltinType {{.*}} 'int'670// CHECK-NEXT: |   |-TemplateArgument {{.*}} type 'auto:1':'type-parameter-0-1'671// CHECK-NEXT: |   | `-TemplateTypeParmType {{.*}} 'auto:1' dependent depth 0 index 1672// CHECK-NEXT: |   |   `-TemplateTypeParm {{.*}} 'auto:1'673// CHECK-NEXT: |   `-TemplateArgument {{.*}} type 'int'674// CHECK-NEXT: |     `-BuiltinType {{.*}} 'int'675// CHECK-NEXT: |-TypeTraitExpr {{.*}} 'bool' __is_deducible676// CHECK-NEXT: | |-DeducedTemplateSpecializationType {{.*}} 'GH122134::Test' dependent677// CHECK-NEXT: | | `-name: 'GH122134::Test'678// CHECK-NEXT: | |   `-TypeAliasTemplateDecl {{.*}} Test679// CHECK-NEXT: | `-TemplateSpecializationType {{.*}} 'GH122134::Struct<int, N>' dependent680// CHECK-NEXT: |   |-name: 'GH122134::Struct'681// CHECK-NEXT: |   | `-ClassTemplateDecl {{.*}} Struct682// CHECK-NEXT: |   |-TemplateArgument type 'int'683// CHECK-NEXT: |   | `-SubstTemplateTypeParmType {{.*}} 'int' sugar class depth 0 index 0 T684// CHECK-NEXT: |   |   |-FunctionTemplate {{.*}} '<deduction guide for Struct>'685// CHECK-NEXT: |   |   `-BuiltinType {{.*}} 'int'686// CHECK-NEXT: |   `-TemplateArgument expr 'N'687// CHECK-NEXT: |     `-SubstNonTypeTemplateParmExpr {{.*}} 'int'688// CHECK-NEXT: |       |-NonTypeTemplateParmDecl {{.*}} 'int' depth 0 index 1689// CHECK-NEXT: |       `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'N' 'int'690// CHECK-NEXT: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for Test> 'auto (auto:1) -> GH122134::Struct<int, N>'691// CHECK-NEXT: | `-ParmVarDecl {{.*}} 'auto:1'692 693} // namespace GH122134694 695namespace GH128691 {696 697template <typename = void>698class NewDeleteAllocator;699 700template <>701struct NewDeleteAllocator<> {702  template <typename T>703  NewDeleteAllocator(T); // expected-note {{candidate template ignored}} \704                         // expected-note {{implicit deduction guide declared as}}705};706 707template <typename>708struct NewDeleteAllocator : NewDeleteAllocator<> { // expected-note {{candidate template ignored}} \709                                                   // expected-note {{implicit deduction guide declared as}}710  using NewDeleteAllocator<>::NewDeleteAllocator;711};712 713void test() { NewDeleteAllocator abc(42); } // expected-error {{no viable constructor or deduction guide}}714 715// CHECK-LABEL: Dumping GH128691::<deduction guide for NewDeleteAllocator>:716// CHECK-NEXT: FunctionTemplateDecl {{.+}} <deduction guide for NewDeleteAllocator>717// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0718// CHECK-NEXT: | `-TemplateArgument type 'void'719// CHECK-NEXT: |   |-inherited from TemplateTypeParm {{.+}} depth 0 index 0720// CHECK-NEXT: |   `-BuiltinType {{.+}} 'void'721// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 1 T722// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <deduction guide for NewDeleteAllocator> 'auto (T) -> GH128691::NewDeleteAllocator<type-parameter-0-0>'723// CHECK-NEXT:  `-ParmVarDecl {{.+}} 'T'724 725} // namespace GH128691726 727namespace GH132616_DeductionGuide {728 729template <class T> struct A {730  template <class U>731  A(U);732};733 734template <typename>735struct B : A<int> {736  using A::A;737};738 739template <class T>740B(T) -> B<T>;741 742B b(24);743 744// CHECK-LABEL: Dumping GH132616_DeductionGuide::<deduction guide for B>:745// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit <deduction guide for B>746// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0747// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U748// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for B> 'auto (U) -> GH132616_DeductionGuide::B<type-parameter-0-0>'749// CHECK-NEXT:  `-ParmVarDecl {{.+}} 'U'750 751struct C {752  template <class U>753  C(U);754};755 756template <typename>757struct D : C {758  using C::C;759};760 761template <class T>762D(T) -> D<T>;763 764D d(24);765 766// CHECK-LABEL: Dumping GH132616_DeductionGuide::<deduction guide for D>:767// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit <deduction guide for D>768// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0769// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U770// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for D> 'auto (U) -> GH132616_DeductionGuide::D<type-parameter-0-0>'771// CHECK-NEXT:  `-ParmVarDecl {{.+}} 'U'772 773} // namespace GH132616_DeductionGuide774 775namespace GH133132 {776 777template <class _Ty>778struct A {};779 780template <class T = int, class U = T>781using AA = A<U>;782 783AA a{};784 785// CHECK-LABEL: Dumping GH133132::<deduction guide for AA>:786// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit <deduction guide for AA>787// CHECK-NEXT:  |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 T788// CHECK-NEXT:  | `-TemplateArgument type 'int'789// CHECK-NEXT:  |   `-BuiltinType {{.+}} 'int'790// CHECK-NEXT:  |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U791// CHECK-NEXT:  | `-TemplateArgument type 'T':'type-parameter-0-0'792// CHECK-NEXT:  |   `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0793// CHECK-NEXT:  |     `-TemplateTypeParm {{.+}} 'T'794// CHECK-NEXT:  |-TypeTraitExpr {{.+}} 'bool' __is_deducible795// CHECK-NEXT:  | |-DeducedTemplateSpecializationType {{.+}} 'GH133132::AA' dependent796// CHECK-NEXT:  | | `-name: 'GH133132::AA'797// CHECK-NEXT:  | |   `-TypeAliasTemplateDecl {{.+}} AA798// CHECK-NEXT:  | `-TemplateSpecializationType {{.+}} 'GH133132::A<U>' dependent799// CHECK-NEXT:  |   |-name: 'GH133132::A'800// CHECK-NEXT:  |   | `-ClassTemplateDecl {{.+}} A801// CHECK-NEXT:  |   `-TemplateArgument type 'U':'type-parameter-0-1'802// CHECK-NEXT:  |     `-SubstTemplateTypeParmType {{.+}} 'U' sugar dependent class depth 0 index 0 _Ty803// CHECK-NEXT:  |       |-FunctionTemplate {{.+}} '<deduction guide for A>'804// CHECK-NEXT:  |       `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1805// CHECK-NEXT:  |         `-TemplateTypeParm {{.+}} 'U'806// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for AA> 'auto () -> GH133132::A<U>'807// CHECK-NEXT:  `-CXXDeductionGuideDecl {{.+}} implicit used <deduction guide for AA> 'auto () -> GH133132::A<int>' implicit_instantiation808// CHECK-NEXT:    |-TemplateArgument type 'int'809// CHECK-NEXT:    | `-BuiltinType {{.+}} 'int'810// CHECK-NEXT:    `-TemplateArgument type 'int'811// CHECK-NEXT:      `-BuiltinType {{.+}} 'int'812 813template <template <class> class _X>814struct B {};815 816template <template <class> class _X = A, template <class> class _Y = _X>817using BB = B<_Y>;818 819BB b{};820 821// CHECK-LABEL: Dumping GH133132::<deduction guide for BB>:822// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit <deduction guide for BB>823// CHECK-NEXT:  |-TemplateTemplateParmDecl {{.+}} depth 0 index 0 _X824// CHECK-NEXT:  | |-TemplateTypeParmDecl {{.+}} class depth 0 index 0825// CHECK-NEXT:  | `-TemplateArgument {{.+}} template 'A':'GH133132::A' qualified826// CHECK-NEXT:  |   `-ClassTemplateDecl {{.+}} A827// CHECK-NEXT:  |-TemplateTemplateParmDecl {{.+}} depth 0 index 1 _Y828// CHECK-NEXT:  | |-TemplateTypeParmDecl {{.+}} class depth 0 index 0829// CHECK-NEXT:  | `-TemplateArgument {{.+}} template '_X':'template-parameter-0-0'830// CHECK-NEXT:  |   `-TemplateTemplateParmDecl {{.+}} depth 0 index 0 _X831// CHECK-NEXT:  |-TypeTraitExpr {{.+}} 'bool' __is_deducible832// CHECK-NEXT:  | |-DeducedTemplateSpecializationType {{.+}} 'GH133132::BB' dependent833// CHECK-NEXT:  | | `-name: 'GH133132::BB'834// CHECK-NEXT:  | |   `-TypeAliasTemplateDecl {{.+}} BB835// CHECK-NEXT:  | `-TemplateSpecializationType {{.+}} 'GH133132::B<_Y>' dependent836// CHECK-NEXT:  |   |-name: 'GH133132::B'837// CHECK-NEXT:  |   | `-ClassTemplateDecl {{.+}} B838// CHECK-NEXT:  |   `-TemplateArgument template '_Y':'template-parameter-0-1' subst index 0839// CHECK-NEXT:  |     |-parameter: TemplateTemplateParmDecl {{.+}} depth 0 index 0 _X840// CHECK-NEXT:  |     |-associated FunctionTemplate {{.+}} '<deduction guide for B>'841// CHECK-NEXT:  |     `-replacement: '_Y':'template-parameter-0-1'842// CHECK-NEXT:  |       `-TemplateTemplateParmDecl {{.+}} depth 0 index 1 _Y843// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for BB> 'auto () -> GH133132::B<_Y>'844// CHECK-NEXT:  `-CXXDeductionGuideDecl {{.+}} implicit used <deduction guide for BB> 'auto () -> GH133132::B<GH133132::A>' implicit_instantiation845// CHECK-NEXT:    |-TemplateArgument template 'GH133132::A'846// CHECK-NEXT:    | `-ClassTemplateDecl {{.+}} A847// CHECK-NEXT:    `-TemplateArgument template 'GH133132::A'848// CHECK-NEXT:      `-ClassTemplateDecl {{.+}} A849 850template <int N = 42, class U = A<decltype(N)>>851using CC = A<U>;852 853CC c{};854 855// CHECK-LABEL: Dumping GH133132::<deduction guide for CC>:856// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit <deduction guide for CC>857// CHECK-NEXT:  |-NonTypeTemplateParmDecl {{.+}} 'int' depth 0 index 0 N858// CHECK-NEXT:  | `-TemplateArgument {{.+}} expr '42'859// CHECK-NEXT:  |   `-IntegerLiteral {{.+}} 'int' 42860// CHECK-NEXT:  |-TemplateTypeParmDecl {{.+}} class depth 0 index 1 U861// CHECK-NEXT:  | `-TemplateArgument type 'A<decltype(N)>'862// CHECK-NEXT:  |   `-TemplateSpecializationType {{.+}} 'A<decltype(N)>' dependent863// CHECK-NEXT:  |     |-name: 'A':'GH133132::A' qualified864// CHECK-NEXT:  |     | `-ClassTemplateDecl {{.+}} A865// CHECK-NEXT:  |     `-TemplateArgument type 'decltype(N)'866// CHECK-NEXT:  |       `-DecltypeType {{.+}} 'decltype(N)' dependent867// CHECK-NEXT:  |         `-DeclRefExpr {{.+}} 'int' NonTypeTemplateParm {{.+}} 'N' 'int'868// CHECK-NEXT:  |-TypeTraitExpr {{.+}} 'bool' __is_deducible869// CHECK-NEXT:  | |-DeducedTemplateSpecializationType {{.+}} 'GH133132::CC' dependent870// CHECK-NEXT:  | | `-name: 'GH133132::CC'871// CHECK-NEXT:  | |   `-TypeAliasTemplateDecl {{.+}} CC872// CHECK-NEXT:  | `-TemplateSpecializationType {{.+}} 'GH133132::A<U>' dependent873// CHECK-NEXT:  |   |-name: 'GH133132::A'874// CHECK-NEXT:  |   | `-ClassTemplateDecl {{.+}} A875// CHECK-NEXT:  |   `-TemplateArgument type 'U':'type-parameter-0-1'876// CHECK-NEXT:  |     `-SubstTemplateTypeParmType {{.+}} 'U' sugar dependent class depth 0 index 0 _Ty877// CHECK-NEXT:  |       |-FunctionTemplate {{.+}} '<deduction guide for A>'878// CHECK-NEXT:  |       `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1879// CHECK-NEXT:  |         `-TemplateTypeParm {{.+}} 'U'880// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for CC> 'auto () -> GH133132::A<U>'881// CHECK-NEXT:  `-CXXDeductionGuideDecl {{.+}} implicit used <deduction guide for CC> 'auto () -> GH133132::A<GH133132::A<int>>' implicit_instantiation882// CHECK-NEXT:    |-TemplateArgument integral '42'883// CHECK-NEXT:    `-TemplateArgument type 'GH133132::A<int>'884// CHECK-NEXT:      `-RecordType {{.+}} 'GH133132::A<int>'885// CHECK-NEXT:        `-ClassTemplateSpecialization {{.+}} 'A'886 887}888 889namespace GH67173 {890 891template <class T> struct Vec2d {892  struct {893    T x;894    T y;895  };896};897 898void f() {899  Vec2d v{.x = 1, .y = 2};900}901 902// CHECK-LABEL: Dumping GH67173::<deduction guide for Vec2d>:903// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit <deduction guide for Vec2d>904// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} referenced class depth 0 index 0 T905// CHECK:      |-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for Vec2d> 'auto (T, T) -> GH67173::Vec2d<T>' aggregate906// CHECK-NEXT: | |-ParmVarDecl {{.+}} col:27 'T'907// CHECK-NEXT: | `-ParmVarDecl {{.+}} col:27 'T'908// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit used <deduction guide for Vec2d> 'auto (int, int) -> GH67173::Vec2d<int>' implicit_instantiation instantiated_from 0x{{.+}} aggregate909// CHECK-NEXT:   |-TemplateArgument type 'int'910// CHECK-NEXT:   | `-BuiltinType {{.+}} 'int'911// CHECK-NEXT:   |-ParmVarDecl {{.+}} 'int'912// CHECK-NEXT:   `-ParmVarDecl {{.+}} 'int'913 914}915 916namespace GH141425 {917 918template<class... Lambda>919struct Container920{921    Container(Lambda...) {}922};923 924template<class... T>925using Alias = Container<T...>;926 927template<class = void>928struct Invocable {929    using T = decltype([]() {930        (void)Alias([]() -> void {});931    }());932};933 934struct Type {935    using T = bool;936};937 938template<class...>939struct ExpandType {940    using T = bool;941};942 943template<class... X>944using Expand = ExpandType<typename X::T...>;945 946Expand<Type, Invocable<>> _{};947 948// CHECK-LABEL: Dumping GH141425::<deduction guide for Alias>:949// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit <deduction guide for Alias>950// CHECK-NEXT:   |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 ... T951// CHECK-NEXT:   |-TypeTraitExpr {{.+}} 'bool' __is_deducible952// CHECK-NEXT:   | |-DeducedTemplateSpecializationType {{.+}} 'GH141425::Alias' dependent953// CHECK-NEXT:   | | `-name: 'GH141425::Alias'954// CHECK-NEXT:   | |   `-TypeAliasTemplateDecl {{.+}} Alias955// CHECK-NEXT:   | `-TemplateSpecializationType {{.+}} 'GH141425::Container<T...>' dependent956// CHECK-NEXT:   |   |-name: 'GH141425::Container'957// CHECK-NEXT:   |   | `-ClassTemplateDecl {{.+}} Container958// CHECK-NEXT:   |   `-TemplateArgument type 'T...':'type-parameter-0-0...'959// CHECK-NEXT:   |     `-PackExpansionType {{.+}} 'T...' dependent960// CHECK-NEXT:   |       `-SubstTemplateTypeParmType {{.+}} 'T' sugar dependent contains_unexpanded_pack class depth 0 index 0 ... Lambda pack_index 0961// CHECK-NEXT:   |         |-FunctionTemplate {{.+}} '<deduction guide for Container>'962// CHECK-NEXT:   |         `-TemplateTypeParmType {{.+}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack963// CHECK-NEXT:   |           `-TemplateTypeParm {{.+}} 'T'964// CHECK-NEXT:   |-CXXDeductionGuideDecl {{.+}} implicit <deduction guide for Alias> 'auto (T...) -> GH141425::Container<T...>'965// CHECK-NEXT:   | `-ParmVarDecl {{.+}} 'T...' pack966 967}968 969namespace GH134613 {970template <typename R> struct Foo {971  using value_type = R;972 973  Foo() = default;974  Foo(Foo<Foo<R>> &&rhs) {}975};976 977void main() {978  auto r1 = Foo(Foo<Foo<int>>{});979 980  static_assert(__is_same(decltype(r1)::value_type, int));981}982 983}984