1 // RUN: %clang_cc1 -std=c++2a -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace 2 3 template<auto ...> struct X {}; 4 template<template<typename X, X> typename> struct Y {}; 5 template<typename ...> struct Z {}; 6 7 template<typename T, typename ...Ts> struct A { 8 template<Ts ...Ns, T *...Ps> A(X<Ps...>, Ts (*...qs)[Ns]); 9 }; 10 int arr1[3], arr2[3]; 11 short arr3[4]; 12 A a(X<&arr1, &arr2>{}, &arr1, &arr2, &arr3); 13 using AT = decltype(a); 14 using AT = A<int[3], int, int, short>; 15 16 // CHECK-LABEL: Dumping <deduction guide for A>: 17 // CHECK: FunctionTemplateDecl 18 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T 19 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 ... Ts 20 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'Ts...' depth 0 index 2 ... Ns 21 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'T *' depth 0 index 3 ... Ps 22 // CHECK: |-CXXDeductionGuideDecl 23 // CHECK: | |-ParmVarDecl {{.*}} 'X<Ps...>' 24 // CHECK: | `-ParmVarDecl {{.*}} 'Ts (*)[Ns]...' pack 25 // CHECK: `-CXXDeductionGuideDecl 26 // CHECK: |-TemplateArgument type 'int[3]' 27 // CHECK: |-TemplateArgument pack 28 // CHECK: | |-TemplateArgument type 'int' 29 // CHECK: | |-TemplateArgument type 'int' 30 // CHECK: | `-TemplateArgument type 'short' 31 // CHECK: |-TemplateArgument pack 32 // CHECK: | |-TemplateArgument integral '3' 33 // CHECK: | |-TemplateArgument integral '3' 34 // CHECK: | `-TemplateArgument integral '(short)4' 35 // CHECK: |-TemplateArgument pack 36 // CHECK: | |-TemplateArgument decl 37 // CHECK: | | `-Var {{.*}} 'arr1' 'int[3]' 38 // CHECK: | `-TemplateArgument decl 39 // 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_return 45 // CHECK: |-InjectedClassNameType {{.*}} 'A<T, Ts...>' dependent 46 // CHECK: |-ElaboratedType {{.*}} 'X<Ps...>' sugar dependent 47 // CHECK: | `-TemplateSpecializationType {{.*}} 'X<Ps...>' dependent 48 // CHECK: | `-TemplateArgument expr 49 // CHECK: | `-PackExpansionExpr {{.*}} 'T *' 50 // CHECK: | `-DeclRefExpr {{.*}} 'T *' NonTypeTemplateParm {{.*}} 'Ps' 'T *' 51 // CHECK: `-PackExpansionType {{.*}} 'Ts (*)[Ns]...' dependent 52 // CHECK: `-PointerType {{.*}} 'Ts (*)[Ns]' dependent contains_unexpanded_pack 53 // CHECK: `-ParenType {{.*}} 'Ts[Ns]' sugar dependent contains_unexpanded_pack 54 // CHECK: `-DependentSizedArrayType {{.*}} 'Ts[Ns]' dependent contains_unexpanded_pack 55 // CHECK: |-TemplateTypeParmType {{.*}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack 56 // CHECK: | `-TemplateTypeParm {{.*}} 'Ts' 57 // CHECK: `-DeclRefExpr {{.*}} 'Ts' NonTypeTemplateParm {{.*}} 'Ns' 'Ts...' 58 59 template<typename T, T V> struct B { 60 template<typename U, U W> B(X<W, V>); 61 }; 62 B b(X<nullptr, 'x'>{}); 63 using BT = decltype(b); 64 using BT = B<char, 'x'>; 65 66 // CHECK-LABEL: Dumping <deduction guide for B>: 67 // CHECK: FunctionTemplateDecl 68 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T 69 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'T' depth 0 index 1 V 70 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U 71 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'U' depth 0 index 3 W 72 // CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (X<W, V>) -> B<T, V>' 73 // CHECK: | `-ParmVarDecl {{.*}} 'X<W, V>' 74 // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (X<nullptr, 'x'>) -> B<char, 'x'>' 75 // CHECK: |-TemplateArgument type 'char' 76 // CHECK: |-TemplateArgument integral ''x'' 77 // CHECK: |-TemplateArgument type 'std::nullptr_t' 78 // CHECK: |-TemplateArgument nullptr 79 // CHECK: `-ParmVarDecl {{.*}} 'X<nullptr, 'x'>' 80 // CHECK: FunctionProtoType {{.*}} 'auto (X<W, V>) -> B<T, V>' dependent trailing_return 81 // CHECK: |-InjectedClassNameType {{.*}} 'B<T, V>' dependent 82 // CHECK: `-TemplateSpecializationType {{.*}} 'X<W, V>' dependent 83 // CHECK: |-TemplateArgument expr 84 // CHECK: | `-DeclRefExpr {{.*}} 'U' NonTypeTemplateParm {{.*}} 'W' 'U' 85 // CHECK: `-TemplateArgument expr 86 // CHECK: `-DeclRefExpr {{.*}} 'T' NonTypeTemplateParm {{.*}} 'V' 'T' 87 88 template<typename A> struct C { 89 template<template<typename X, X> typename T, typename U, U V = 0> C(A, Y<T>, U); 90 }; 91 C c(1, Y<B>{}, 2); 92 using CT = decltype(c); 93 using CT = C<int>; 94 95 // CHECK-LABEL: Dumping <deduction guide for C>: 96 // CHECK: FunctionTemplateDecl 97 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 A 98 // CHECK: |-TemplateTemplateParmDecl {{.*}} depth 0 index 1 T 99 // CHECK: | |-TemplateTypeParmDecl {{.*}} typename depth 1 index 0 X 100 // CHECK: | `-NonTypeTemplateParmDecl {{.*}} 'X' depth 1 index 1 101 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U 102 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'U' depth 0 index 3 V 103 // CHECK: | `-TemplateArgument {{.*}} expr 104 // CHECK: | `-IntegerLiteral {{.*}} 'int' 0 105 // CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (A, Y<T>, U) -> C<A>' 106 // CHECK: | |-ParmVarDecl {{.*}} 'A' 107 // CHECK: | |-ParmVarDecl {{.*}} 'Y<T>' 108 // CHECK: | `-ParmVarDecl {{.*}} 'U' 109 // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (int, Y<B>, int) -> C<int>' 110 // CHECK: |-TemplateArgument type 'int' 111 // CHECK: |-TemplateArgument template 'B' 112 // CHECK: |-TemplateArgument type 'int' 113 // CHECK: |-TemplateArgument integral '0' 114 // CHECK: |-ParmVarDecl {{.*}} 'int' 115 // CHECK: |-ParmVarDecl {{.*}} 'Y<B>' 116 // CHECK: `-ParmVarDecl {{.*}} 'int' 117 // CHECK: FunctionProtoType {{.*}} 'auto (A, Y<T>, U) -> C<A>' dependent trailing_return cdecl 118 // CHECK: |-InjectedClassNameType {{.*}} 'C<A>' dependent 119 // CHECK: |-TemplateTypeParmType {{.*}} 'A' dependent depth 0 index 0 120 // CHECK: | `-TemplateTypeParm {{.*}} 'A' 121 // CHECK: |-ElaboratedType {{.*}} 'Y<T>' sugar dependent 122 // CHECK: | `-TemplateSpecializationType {{.*}} 'Y<T>' dependent 123 // CHECK: | `-TemplateArgument template 124 // CHECK: `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 2 125 126 template<typename ...T> struct D { // expected-note {{candidate}} \ 127 // expected-note {{implicit deduction guide declared as 'template <typename ...T> D(D<T...>) -> D<T...>'}} 128 template<typename... U> using B = int(int (*...p)(T, U)); 129 template<typename U1, typename U2> D(B<U1, U2>*); // expected-note {{candidate}} \ 130 // expected-note {{implicit deduction guide declared as 'template <typename ...T, typename U1, typename U2> D(B<U1, U2> *) -> D<T...>'}} 131 }; 132 int f(int(int, int), int(int, int)); 133 // FIXME: We can't deduce this because we can't deduce through a 134 // SubstTemplateTypeParmPackType. 135 D d = f; // expected-error {{no viable}} 136 using DT = decltype(d); 137 using DT = D<int, int>; 138 139 // CHECK-LABEL: Dumping <deduction guide for D>: 140 // CHECK: FunctionTemplateDecl 141 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 ... T 142 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 U1 143 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 2 U2 144 // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (B<U1, U2> *) -> D<T...>' 145 // CHECK: `-ParmVarDecl {{.*}} 'B<U1, U2> *' 146 // CHECK: FunctionProtoType {{.*}} 'auto (B<U1, U2> *) -> D<T...>' dependent trailing_return 147 // CHECK: |-InjectedClassNameType {{.*}} 'D<T...>' dependent 148 // CHECK: `-PointerType {{.*}} 'B<U1, U2> *' dependent 149 // CHECK: `-TemplateSpecializationType {{.*}} 'B<U1, U2>' sugar dependent alias 150 // CHECK: |-TemplateArgument type 'U1' 151 // CHECK: |-TemplateArgument type 'U2' 152 // CHECK: `-FunctionProtoType {{.*}} 'int (int (*)(T, U)...)' dependent cdecl 153 // CHECK: |-BuiltinType {{.*}} 'int' 154 // CHECK: `-PackExpansionType {{.*}} 'int (*)(T, U)...' dependent expansions 2 155 // CHECK: `-PointerType {{.*}} 'int (*)(T, U)' dependent contains_unexpanded_pack 156 // CHECK: `-ParenType {{.*}} 'int (T, U)' sugar dependent contains_unexpanded_pack 157 // CHECK: `-FunctionProtoType {{.*}} 'int (T, U)' dependent contains_unexpanded_pack cdecl 158 // CHECK: |-BuiltinType {{.*}} 'int' 159 // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack 160 // CHECK: | `-TemplateTypeParm {{.*}} 'T' 161 // CHECK: `-SubstTemplateTypeParmPackType {{.*}} 'U' dependent contains_unexpanded_pack typename depth 1 index 0 ... U 162 // CHECK: |-TypeAliasTemplate {{.*}} 'B' 163 // CHECK: `-TemplateArgument pack 164 // CHECK: |-TemplateArgument type 'U1':'type-parameter-0-1' 165 // CHECK-NOT: Subst 166 // CHECK: | `-TemplateTypeParmType 167 // CHECK: `-TemplateArgument type 'U2':'type-parameter-0-2' 168 // CHECK-NOT: Subst 169 // CHECK: `-TemplateTypeParmType 170 171 template<int ...N> struct E { // expected-note {{candidate}} \ 172 expected-note {{implicit deduction guide declared as 'template <int ...N> E(E<N...>) -> E<N...>'}} 173 template<int ...M> using B = Z<X<N, M>...>; 174 template<int M1, int M2> E(B<M1, M2>); // expected-note {{candidate}} \ 175 // expected-note {{implicit deduction guide declared as 'template <int ...N, int M1, int M2> E(B<M1, M2>) -> E<N...>'}}}} 176 }; 177 // FIXME: We can't deduce this because we can't deduce through a 178 // SubstNonTypeTemplateParmPackExpr. 179 E e = Z<X<1, 2>, X<3, 4>>(); // expected-error {{no viable}} 180 using ET = decltype(e); 181 using ET = E<1, 3>; 182 183 // CHECK-LABEL: Dumping <deduction guide for E>: 184 // CHECK: FunctionTemplateDecl 185 // CHECK: |-NonTypeTemplateParmDecl [[N:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 0 ... N 186 // CHECK: |-NonTypeTemplateParmDecl [[M1:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 1 M1 187 // CHECK: |-NonTypeTemplateParmDecl [[M2:0x[0-9a-f]*]] {{.*}} 'int' depth 0 index 2 M2 188 // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (B<M1, M2>) -> E<N...>' 189 // CHECK: `-ParmVarDecl {{.*}} 'B<M1, M2>':'Z<X<N, M>...>' 190 // CHECK: FunctionProtoType {{.*}} 'auto (B<M1, M2>) -> E<N...>' dependent trailing_return 191 // CHECK: |-InjectedClassNameType {{.*}} 'E<N...>' dependent 192 // CHECK: `-TemplateSpecializationType {{.*}} 'B<M1, M2>' sugar dependent alias 193 // CHECK: |-TemplateArgument expr 194 // CHECK: | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'M1' 'int' 195 // CHECK: |-TemplateArgument expr 196 // CHECK: | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'M2' 'int' 197 // CHECK: `-TemplateSpecializationType {{.*}} 'Z<X<N, M>...>' dependent 198 // CHECK: `-TemplateArgument type 'X<N, M>...' 199 // CHECK: `-PackExpansionType {{.*}} 'X<N, M>...' dependent expansions 2 200 // CHECK: `-TemplateSpecializationType {{.*}} 'X<N, M>' dependent contains_unexpanded_pack 201 // CHECK: |-TemplateArgument expr 202 // CHECK-NOT: Subst 203 // CHECK: | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[N]] 'N' 'int' 204 // CHECK: `-TemplateArgument expr 205 // CHECK: `-SubstNonTypeTemplateParmPackExpr {{.*}} 'int' 206 // CHECK: |-NonTypeTemplateParmDecl {{.*}} referenced 'int' depth 1 index 0 ... M 207 // CHECK: `-TemplateArgument pack 208 // CHECK: |-TemplateArgument expr 209 // CHECK-NOT: Subst 210 // CHECK: | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[M1]] 'M1' 'int' 211 // CHECK: `-TemplateArgument expr 212 // CHECK-NOT: Subst 213 // CHECK: `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm [[M2]] 'M2' 'int' 214 215 template <char = 'x'> struct F; 216 217 template <char> struct F { 218 template <typename U> 219 requires(false) F(U); 220 template <typename U> 221 requires(true) F(U); 222 }; 223 224 F s(0); 225 226 // CHECK-LABEL: Dumping <deduction guide for F>: 227 // CHECK: FunctionTemplateDecl 228 // CHECK: |-NonTypeTemplateParmDecl {{.*}} 'char' depth 0 index 0 229 // CHECK: `-TemplateArgument {{.*}} expr 230 // CHECK: | |-inherited from NonTypeTemplateParm {{.*}} depth 0 index 0 'char' 231 // CHECK: | `-CharacterLiteral {{.*}} 'char' 120 232 // CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 U 233 // CHECK: |-ParenExpr {{.*}} 'bool' 234 // CHECK: | `-CXXBoolLiteralExpr {{.*}} 'bool' false 235 // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (U) -> F<value-parameter-0-0>' 236 // CHECK: | `-ParmVarDecl {{.*}} 'U' 237 // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (int) -> F<>' 238 // CHECK: |-TemplateArgument integral ''x'' 239 // CHECK: |-TemplateArgument type 'int' 240 // CHECK: | `-BuiltinType {{.*}} 'int' 241 // CHECK: `-ParmVarDecl {{.*}} 'int' 242 // CHECK: FunctionProtoType {{.*}} 'auto (U) -> F<value-parameter-0-0>' dependent trailing_return cdecl 243 // CHECK: |-InjectedClassNameType {{.*}} 'F<value-parameter-0-0>' dependent 244 // CHECK: | `-CXXRecord {{.*}} 'F' 245 // CHECK: `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 1 246 247 template<typename T> 248 struct G { T t; }; 249 250 G g = {1}; 251 // CHECK-LABEL: Dumping <deduction guide for G>: 252 // CHECK: FunctionTemplateDecl 253 // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for G> 'auto (T) -> G<T>' aggregate 254 // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for G> 'auto (int) -> G<int>' implicit_instantiation aggregate 255 256 template<typename X> 257 using AG = G<X>; 258 AG ag = {1}; 259 // Verify that the aggregate deduction guide for alias templates is built. 260 // CHECK-LABEL: Dumping <deduction guide for AG> 261 // CHECK: FunctionTemplateDecl 262 // CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (X) -> G<X>' 263 // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' implicit_instantiation 264 // CHECK: |-TemplateArgument type 'int' 265 // CHECK: | `-BuiltinType {{.*}} 'int' 266 // CHECK: `-ParmVarDecl {{.*}} 'int' 267 268 template <typename X = int> 269 using BG = G<int>; 270 BG bg(1.0); 271 // CHECK-LABEL: Dumping <deduction guide for BG> 272 // CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for BG> 273 // CHECK: |-CXXDeductionGuideDecl {{.*}} 'auto (int) -> G<int>' aggregate 274 275 template <typename D> 276 requires (sizeof(D) == 4) 277 struct Foo { 278 Foo(D); 279 }; 280 281 template <typename U> 282 using AFoo = Foo<G<U>>; 283 // Verify that the require-clause from the Foo deduction guide is transformed. 284 // The D occurrence should be rewritten to G<U>. 285 // 286 // CHECK-LABEL: Dumping <deduction guide for AFoo> 287 // CHECK: FunctionTemplateDecl {{.*}} implicit <deduction guide for AFoo> 288 // CHECK-NEXT: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 0 U 289 // CHECK-NEXT: |-BinaryOperator {{.*}} '&&' 290 // CHECK-NEXT: | |-ParenExpr {{.*}} 'bool' 291 // CHECK-NEXT: | | `-BinaryOperator {{.*}} 'bool' '==' 292 // CHECK-NEXT: | | |-UnaryExprOrTypeTraitExpr {{.*}} 'G<U>' 293 // CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} 294 // CHECK-NEXT: | | `-IntegerLiteral {{.*}} 295 // CHECK-NEXT: | `-TypeTraitExpr {{.*}} 'bool' __is_deducible 296 // CHECK-NEXT: | |-DeducedTemplateSpecializationType {{.*}} 'AFoo' dependent 297 // CHECK-NEXT: | | `-name: 'AFoo' 298 // CHECK-NEXT: | | `-TypeAliasTemplateDecl {{.+}} AFoo 299 // CHECK-NEXT: | `-TemplateSpecializationType {{.*}} 'Foo<G<U>>' dependent 300 // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for AFoo> 'auto (G<U>) -> Foo<G<U>>' 301 // CHECK-NEXT: | `-ParmVarDecl {{.*}} 'G<U>' 302 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for AFoo> 'auto (G<int>) -> Foo<G<int>>' implicit_instantiation 303 // CHECK-NEXT: |-TemplateArgument type 'int' 304 // CHECK-NEXT: | `-BuiltinType {{.*}} 'int' 305 // CHECK-NEXT: `-ParmVarDecl {{.*}} 'G<int>' 306 307 AFoo aa(G<int>{}); 308 309 namespace TTP { 310 template<typename> struct A {}; 311 312 template<class T> struct B { 313 template<template <class> typename TT> B(TT<T>); 314 }; 315 316 B b(A<int>{}); 317 } // namespace TTP 318 319 // CHECK-LABEL: Dumping TTP::<deduction guide for B>: 320 // CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[# @LINE - 7]]:5, col:51> 321 // CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 T{{$}} 322 // CHECK-NEXT: |-TemplateTemplateParmDecl {{.+}} depth 0 index 1 TT{{$}} 323 // CHECK-NEXT: | `-TemplateTypeParmDecl {{.+}} class depth 1 index 0{{$}} 324 // CHECK-NEXT: |-CXXDeductionGuideDecl {{.+}} 'auto (TT<T>) -> B<T>'{{$}} 325 // CHECK-NEXT: | `-ParmVarDecl {{.+}} 'TT<T>'{{$}} 326 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} 'auto (A<int>) -> TTP::B<int>' 327 // CHECK-NEXT: |-TemplateArgument type 'int' 328 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int'{{$}} 329 // CHECK-NEXT: |-TemplateArgument template 'TTP::A'{{$}} 330 // CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A{{$}} 331 // CHECK-NEXT: `-ParmVarDecl {{.+}} 'A<int>':'TTP::A<int>'{{$}} 332 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (TT<T>) -> B<T>' dependent trailing_return cdecl{{$}} 333 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'B<T>' dependent{{$}} 334 // CHECK-NEXT: | `-CXXRecord {{.+}} 'B'{{$}} 335 // CHECK-NEXT: `-ElaboratedType {{.+}} 'TT<T>' sugar dependent{{$}} 336 // CHECK-NEXT: `-TemplateSpecializationType {{.+}} 'TT<T>' dependent{{$}} 337 // CHECK-NEXT: |-name: 'TT':'template-parameter-0-1' qualified 338 // CHECK-NEXT: | `-TemplateTemplateParmDecl {{.+}} depth 0 index 1 339 // CHECK-NEXT: `-TemplateArgument type 'T':'type-parameter-0-0'{{$}} 340 // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0{{$}} 341 // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'T'{{$}} 342 343 namespace GH64625 { 344 345 template <class T> struct X { 346 T t[2]; 347 }; 348 349 X x = {{1, 2}}; 350 351 // CHECK-LABEL: Dumping GH64625::<deduction guide for X>: 352 // CHECK-NEXT: FunctionTemplateDecl {{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:27> col:27 implicit <deduction guide for X> 353 // CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:11, col:17> col:17 referenced class depth 0 index 0 T 354 // CHECK: |-CXXDeductionGuideDecl {{.+}} <col:27> col:27 implicit <deduction guide for X> 'auto (T (&&)[2]) -> X<T>' aggregate 355 // CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:27> col:27 'T (&&)[2]' 356 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:27> col:27 implicit used <deduction guide for X> 'auto (int (&&)[2]) -> GH64625::X<int>' implicit_instantiation aggregate 357 // CHECK-NEXT: |-TemplateArgument type 'int' 358 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 359 // CHECK-NEXT: `-ParmVarDecl {{.+}} <col:27> col:27 'int (&&)[2]' 360 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2]) -> X<T>' dependent trailing_return 361 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'X<T>' dependent 362 // CHECK-NEXT: | `-CXXRecord {{.+}} 'X' 363 // CHECK-NEXT: `-RValueReferenceType {{.+}} 'T (&&)[2]' dependent 364 // CHECK-NEXT: `-ConstantArrayType {{.+}} 'T[2]' dependent 2 365 // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0 366 // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'T' 367 368 template <class T, class U> struct TwoArrays { 369 T t[2]; 370 U u[3]; 371 }; 372 373 TwoArrays ta = {{1, 2}, {3, 4, 5}}; 374 // CHECK-LABEL: Dumping GH64625::<deduction guide for TwoArrays>: 375 // CHECK-NEXT: FunctionTemplateDecl {{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:36> col:36 implicit <deduction guide for TwoArrays> 376 // CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:11, col:17> col:17 referenced class depth 0 index 0 T 377 // CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} <col:20, col:26> col:26 referenced class depth 0 index 1 U 378 // CHECK: |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T (&&)[2], U (&&)[3]) -> TwoArrays<T, U>' aggregate 379 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T (&&)[2]' 380 // CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U (&&)[3]' 381 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit used <deduction guide for TwoArrays> 'auto (int (&&)[2], int (&&)[3]) -> GH64625::TwoArrays<int, int>' implicit_instantiation aggregate 382 // CHECK-NEXT: |-TemplateArgument type 'int' 383 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 384 // CHECK-NEXT: |-TemplateArgument type 'int' 385 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 386 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[2]' 387 // CHECK-NEXT: `-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[3]' 388 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2], U (&&)[3]) -> TwoArrays<T, U>' dependent trailing_return 389 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'TwoArrays<T, U>' dependent 390 // CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays' 391 // CHECK-NEXT: |-RValueReferenceType {{.+}} 'T (&&)[2]' dependent 392 // CHECK-NEXT: | `-ConstantArrayType {{.+}} 'T[2]' dependent 2 393 // CHECK-NEXT: | `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0 394 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T' 395 // CHECK-NEXT: `-RValueReferenceType {{.+}} 'U (&&)[3]' dependent 396 // CHECK-NEXT: `-ConstantArrayType {{.+}} 'U[3]' dependent 3 397 // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1 398 // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'U' 399 400 TwoArrays tb = {1, 2, {3, 4, 5}}; 401 // CHECK: |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T, T, U (&&)[3]) -> TwoArrays<T, U>' aggregate 402 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T' 403 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T' 404 // CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U (&&)[3]' 405 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit used <deduction guide for TwoArrays> 'auto (int, int, int (&&)[3]) -> GH64625::TwoArrays<int, int>' implicit_instantiation aggregate 406 // CHECK-NEXT: |-TemplateArgument type 'int' 407 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 408 // CHECK-NEXT: |-TemplateArgument type 'int' 409 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 410 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int' 411 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int' 412 // CHECK-NEXT: `-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[3]' 413 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T, T, U (&&)[3]) -> TwoArrays<T, U>' dependent trailing_return 414 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'TwoArrays<T, U>' dependent 415 // CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays' 416 // CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0 417 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T' 418 // CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0 419 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T' 420 // CHECK-NEXT: `-RValueReferenceType {{.+}} 'U (&&)[3]' dependent 421 // CHECK-NEXT: `-ConstantArrayType {{.+}} 'U[3]' dependent 3 422 // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1 423 // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'U' 424 425 TwoArrays tc = {{1, 2}, 3, 4, 5}; 426 // CHECK: |-CXXDeductionGuideDecl {{.+}} <col:36> col:36 implicit <deduction guide for TwoArrays> 'auto (T (&&)[2], U, U, U) -> TwoArrays<T, U>' aggregate 427 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'T (&&)[2]' 428 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'U' 429 // CHECK-NEXT: | |-ParmVarDecl {{.+}} <col:36> col:36 'U' 430 // CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:36> col:36 'U' 431 // 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 aggregate 432 // CHECK-NEXT: |-TemplateArgument type 'int' 433 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 434 // CHECK-NEXT: |-TemplateArgument type 'int' 435 // CHECK-NEXT: | `-BuiltinType {{.+}} 'int' 436 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int (&&)[2]' 437 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int' 438 // CHECK-NEXT: |-ParmVarDecl {{.+}} <col:36> col:36 'int' 439 // CHECK-NEXT: `-ParmVarDecl {{.+}} <col:36> col:36 'int' 440 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (T (&&)[2], U, U, U) -> TwoArrays<T, U>' dependent trailing_return 441 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'TwoArrays<T, U>' dependent 442 // CHECK-NEXT: | `-CXXRecord {{.+}} 'TwoArrays' 443 // CHECK-NEXT: |-RValueReferenceType {{.+}} 'T (&&)[2]' dependent 444 // CHECK-NEXT: | `-ConstantArrayType {{.+}} 'T[2]' dependent 2 445 // CHECK-NEXT: | `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0 446 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'T' 447 // CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1 448 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'U' 449 // CHECK-NEXT: |-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1 450 // CHECK-NEXT: | `-TemplateTypeParm {{.+}} 'U' 451 // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'U' dependent depth 0 index 1 452 // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'U' 453 454 } // namespace GH64625 455 456 namespace GH83368 { 457 458 template <int N> struct A { 459 int f1[N]; 460 }; 461 462 A a{.f1 = {1}}; 463 464 // CHECK-LABEL: Dumping GH83368::<deduction guide for A>: 465 // CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[#@LINE - 7]]:1, col:25> col:25 implicit <deduction guide for A> 466 // CHECK-NEXT: |-NonTypeTemplateParmDecl {{.+}} <col:11, col:15> col:15 referenced 'int' depth 0 index 0 N 467 // CHECK: |-CXXDeductionGuideDecl {{.+}} <col:25> col:25 implicit <deduction guide for A> 'auto (int (&&)[N]) -> A<N>' aggregate 468 // CHECK-NEXT: | `-ParmVarDecl {{.+}} <col:25> col:25 'int (&&)[N]' 469 // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} <col:25> col:25 implicit used <deduction guide for A> 'auto (int (&&)[1]) -> GH83368::A<1>' implicit_instantiation aggregate 470 // CHECK-NEXT: |-TemplateArgument integral '1' 471 // CHECK-NEXT: `-ParmVarDecl {{.+}} <col:25> col:25 'int (&&)[1]' 472 // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (int (&&)[N]) -> A<N>' dependent trailing_return 473 // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'A<N>' dependent 474 // CHECK-NEXT: | `-CXXRecord {{.+}} 'A' 475 // CHECK-NEXT: `-RValueReferenceType {{.+}} 'int (&&)[N]' dependent 476 // CHECK-NEXT: `-DependentSizedArrayType {{.+}} 'int[N]' dependent 477 // CHECK-NEXT: |-BuiltinType {{.+}} 'int' 478 // CHECK-NEXT: `-DeclRefExpr {{.+}} <col:10> 'int' NonTypeTemplateParm {{.+}} 'N' 'int' 479 480 } // namespace GH83368 481 482 namespace GH60777 { 483 484 template <typename... Ts> constexpr bool True() { return true; } 485 486 template <typename T> 487 requires(sizeof(T) > 1) 488 struct A { 489 template <typename... Ts> 490 requires(sizeof...(Ts) == 0) 491 A(T val, Ts... tail) 492 requires(True<Ts...>()) 493 {} 494 }; 495 496 A a(42); 497 498 // `requires (sizeof(T) > 1)` goes into the deduction guide together with 499 // `requires (True<Ts...>())`, while `requires(sizeof...(Ts) == 0)` goes into 500 // the template parameter list of the synthesized declaration. 501 502 // CHECK-LABEL: Dumping GH60777::<deduction guide for A>: 503 // CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> {{.+}} implicit <deduction guide for A> 504 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:20 referenced typename depth 0 index 0 T 505 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:25 typename depth 0 index 1 ... Ts 506 // CHECK-NEXT: |-ParenExpr 0x{{.+}} <{{.+}}> 'bool' 507 // CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '==' 508 // CHECK-NEXT: | |-SizeOfPackExpr {{.+}} Ts 509 // CHECK-NEXT: | | `-TemplateArgument type 'Ts...':'type-parameter-0-1...' 510 // CHECK-NEXT: | | `-PackExpansionType 0x{{.+}} 'Ts...' dependent 511 // CHECK-NEXT: | | `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack 512 // CHECK-NEXT: | | `-TemplateTypeParm 0x{{.+}} 'Ts' 513 // CHECK-NEXT: | `-ImplicitCastExpr {{.+}} <IntegralCast> 514 // CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 0 515 // CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> line:{{.+}} implicit <deduction guide for A> 'auto (T, Ts...) -> A<T>' 516 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} val 'T' 517 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} tail 'Ts...' pack 518 // CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '&&' 519 // CHECK-NEXT: | |-ParenExpr 0x{{.+}} <{{.+}}> 'bool' 520 // CHECK-NEXT: | | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '>' 521 // CHECK-NEXT: | | |-UnaryExprOrTypeTraitExpr {{.+}} sizeof 'T' 522 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <IntegralCast> 523 // CHECK-NEXT: | | `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 1 524 // CHECK-NEXT: | `-ParenExpr 0x{{.+}} <{{.+}}> '<dependent type>' 525 // CHECK-NEXT: | `-CallExpr 0x{{.+}} <{{.+}}> '<dependent type>' 526 // CHECK-NEXT: | `-UnresolvedLookupExpr 0x{{.+}} <col:14, col:24> '<dependent type>' {{.+}} 527 // CHECK-NEXT: | `-TemplateArgument type 'Ts...':'type-parameter-0-1...' 528 // CHECK-NEXT: | `-PackExpansionType 0x{{.+}} 'Ts...' dependent 529 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack 530 // CHECK-NEXT: | `-TemplateTypeParm 0x{{.+}} 'Ts' 531 532 template <typename T> 533 struct B { 534 template <typename... Ts> 535 B(T val, Ts... tail) 536 requires(True<tail...>()) 537 {} 538 }; 539 540 B b(42, 43); 541 // expected-error@-1 {{no viable constructor}} \ 542 // expected-note@-6 {{constraints not satisfied}} \ 543 // expected-note@-5 {{because substituted constraint expression is ill-formed}} \ 544 // expected-note@-6 {{implicit deduction guide declared as 'template <typename T, typename ...Ts> B(T val, Ts ...tail) -> B<T> requires (True<tail...>())'}} \ 545 // expected-note@-8 {{function template not viable}} \ 546 // expected-note@-8 {{implicit deduction guide declared as 'template <typename T> B(B<T>) -> B<T>'}} 547 548 } // namespace GH60777 549 550 // Examples from @hokein. 551 namespace GH98592 { 552 553 template <class T> concept True = true; 554 double arr3[3]; 555 556 template <class T> 557 struct X { 558 const int size; 559 template <class U> 560 constexpr X(T, U(&)[3]) requires True<T> : size(sizeof(T)) {} 561 }; 562 563 template <typename T, typename U> 564 X(T, U (&)[3]) -> X<U>; 565 566 constexpr X x(3, arr3); 567 568 // The synthesized deduction guide is more constrained than the explicit one. 569 static_assert(x.size == 4); 570 571 // CHECK-LABEL: Dumping GH98592::<deduction guide for X>: 572 // CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for X> 573 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:17 referenced class depth 0 index 0 T 574 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:19 class depth 0 index 1 U 575 // CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for X> 'auto (T, U (&)[3]) -> X<T>' 576 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:15> col:16 'T' 577 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'U (&)[3]' 578 // CHECK-NEXT: | `-ConceptSpecializationExpr 0x{{.+}} <col:36, col:42> 'bool' Concept 0x{{.+}} 'True' 579 // CHECK-NEXT: | |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28 580 // CHECK-NEXT: | | `-TemplateArgument type 'type-parameter-0-0' 581 // CHECK-NEXT: | | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 582 // CHECK-NEXT: | `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0' 583 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0 584 // CHECK-NEXT: | `-TemplateTypeParm 0x{{.+}} 'T' 585 // CHECK-NEXT: `-CXXDeductionGuideDecl 0x{{.+}} <col:3, col:63> col:13 implicit used <deduction guide for X> 'auto (int, double (&)[3]) -> GH98592::X<int>' implicit_instantiation 586 // CHECK-NEXT: |-TemplateArgument type 'int' 587 // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' 588 // CHECK-NEXT: |-TemplateArgument type 'double' 589 // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'double' 590 // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} <col:15> col:16 'int' 591 // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'double (&)[3]' 592 // CHECK-NEXT: `-ConceptSpecializationExpr 0x{{.+}} <col:36, col:42> 'bool' Concept 0x{{.+}} 'True' 593 // CHECK-NEXT: |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28 594 // CHECK-NEXT: | `-TemplateArgument type 'type-parameter-0-0' 595 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 596 // CHECK-NEXT: `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0' 597 // CHECK-NEXT: `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0 598 // CHECK-NEXT: `-TemplateTypeParm 0x{{.+}} 'T' 599 600 template <class T> requires True<T> struct Y { 601 const int size; 602 template <class U> 603 constexpr Y(T, U(&)[3]) : size(sizeof(T)) {} 604 }; 605 606 template <typename T, typename U> Y(T, U (&)[3]) -> Y<U>; 607 608 constexpr Y y(3, arr3); 609 610 // Likewise, the synthesized deduction guide should be preferred 611 // according to [over.match.class.deduct]p1. 612 static_assert(y.size == 4); 613 614 // Dumping GH98592::<deduction guide for Y>: 615 // FunctionTemplateDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for Y> 616 // |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:17 referenced class depth 0 index 0 T 617 // |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:19 class depth 0 index 1 U 618 // |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit <deduction guide for Y> 'auto (T, U (&)[3]) -> Y<T>' 619 // | |-ParmVarDecl 0x{{.+}} <col:15> col:16 'T' 620 // | |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'U (&)[3]' 621 // | `-ConceptSpecializationExpr 0x{{.+}} <{{.+}}> 'bool' Concept 0x{{.+}} 'True' 622 // | |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28 623 // | | `-TemplateArgument type 'type-parameter-0-0' 624 // | | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 625 // | `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0' 626 // | `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0 627 // | `-TemplateTypeParm 0x{{.+}} 'T' 628 // `-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit used <deduction guide for Y> 'auto (int, double (&)[3]) -> GH98592::Y<int>' implicit_instantiation 629 // |-TemplateArgument type 'int' 630 // | `-BuiltinType 0x{{.+}} 'int' 631 // |-TemplateArgument type 'double' 632 // | `-BuiltinType 0x{{.+}} 'double' 633 // |-ParmVarDecl 0x{{.+}} <col:15> col:16 'int' 634 // |-ParmVarDecl 0x{{.+}} <col:18, col:24> col:21 'double (&)[3]' 635 // `-ConceptSpecializationExpr 0x{{.+}} <{{.+}}> 'bool' Concept 0x{{.+}} 'True' 636 // |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28 637 // | `-TemplateArgument type 'type-parameter-0-0' 638 // | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 639 // `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0' 640 // `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 index 0 641 // `-TemplateTypeParm 0x{{.+}} 'T' 642 643 } // namespce GH98592 644 645 namespace GH122134 { 646 647 template <class, class> 648 concept Constraint = true; 649 650 template <class T, int> struct Struct { 651 Struct(Constraint<T> auto) {} 652 }; 653 654 template <int N = 0> using Test = Struct<int, N>; 655 656 Test test(42); 657 658 // CHECK-LABEL: Dumping GH122134::<deduction guide for Test>: 659 // CHECK-NEXT: FunctionTemplateDecl {{.*}} implicit <deduction guide for Test> 660 // CHECK-NEXT: |-NonTypeTemplateParmDecl {{.*}} 'int' depth 0 index 0 N 661 // CHECK-NEXT: | `-TemplateArgument {{.*}} expr '0' 662 // CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 0 663 // CHECK-NEXT: |-TemplateTypeParmDecl {{.*}} Concept {{.*}} 'Constraint' depth 0 index 1 auto:1 664 // CHECK-NEXT: | `-ConceptSpecializationExpr {{.*}} 'bool' Concept {{.*}} 'Constraint' 665 // CHECK-NEXT: | |-ImplicitConceptSpecializationDecl {{.*}} 666 // CHECK-NEXT: | | |-TemplateArgument type 'type-parameter-0-1' 667 // CHECK-NEXT: | | | `-TemplateTypeParmType {{.*}} 'type-parameter-0-1' dependent depth 0 index 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 1 672 // CHECK-NEXT: | | `-TemplateTypeParm {{.*}} 'auto:1' 673 // CHECK-NEXT: | `-TemplateArgument {{.*}} type 'int' 674 // CHECK-NEXT: | `-BuiltinType {{.*}} 'int' 675 // CHECK-NEXT: |-TypeTraitExpr {{.*}} 'bool' __is_deducible 676 // CHECK-NEXT: | |-DeducedTemplateSpecializationType {{.*}} 'GH122134::Test' dependent 677 // CHECK-NEXT: | | `-name: 'GH122134::Test' 678 // CHECK-NEXT: | | `-TypeAliasTemplateDecl {{.*}} Test 679 // CHECK-NEXT: | `-TemplateSpecializationType {{.*}} 'Struct<int, N>' dependent 680 // CHECK-NEXT: | |-name: 'Struct':'GH122134::Struct' qualified 681 // CHECK-NEXT: | | `-ClassTemplateDecl {{.*}} Struct 682 // CHECK-NEXT: | |-TemplateArgument type 'int' 683 // CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 'int' sugar class depth 0 index 0 T 684 // 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 1 689 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'N' 'int' 690 // CHECK-NEXT: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for Test> 'auto (auto:1) -> Struct<int, N>' 691 // CHECK-NEXT: | `-ParmVarDecl {{.*}} 'auto:1' 692 693 } // namespace GH122134 694