<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85767>85767</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
CTAD: missing aggregate deduction guides for alias templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
hokein
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hokein
</td>
</tr>
</table>
<pre>
The following code is an example for aggregate deduction guides.
```
template <typename T1, typename T2>
struct Foo {
T1 t1;
T2 t2;
};
template<typename X, typename Y>
using A = Foo<X, Y>;
A a = {1, 2};
```
The related AST `DeductionGuideDecl` nodes look like:
```
|-FunctionTemplateDecl 0x5633ce70b420 <line:7:1, line:8:19> col:1 implicit <deduction guide for A>
| |-TemplateTypeParmDecl 0x5633ce70ad90 <line:7:10, col:19> col:19 typename depth 0 index 0 X
| |-TemplateTypeParmDecl 0x5633ce70ae18 <col:22, col:31> col:31 typename depth 0 index 1 Y
| `-CXXDeductionGuideDecl 0x5633ce70b360 <col:1, line:8:19> col:1 implicit <deduction guide for A> 'auto () -> Foo<type-parameter-0-0, type-parameter-0-1>'
|-FunctionTemplateDecl 0x5633ce70c458 <line:7:1, line:8:19> col:1 implicit <deduction guide for A>
| |-TemplateTypeParmDecl 0x5633ce70b480 <line:7:10, col:19> col:19 typename depth 0 index 0 X
| |-TemplateTypeParmDecl 0x5633ce70b508 <col:22, col:31> col:31 typename depth 0 index 1 Y
| `-CXXDeductionGuideDecl 0x5633ce70c390 <col:1, line:8:19> col:1 implicit <deduction guide for A> 'auto (Foo<type-parameter-0-0, type-parameter-0-1>) -> Foo<type-parameter-0-0, type-parameter-0-1>'
| `-ParmVarDecl 0x5633ce70b8e8 <line:2:8> col:8 'Foo<type-parameter-0-0, type-parameter-0-1>'
`-FunctionTemplateDecl 0x5633ce70c748 <line:1:1, line:2:8> col:8 implicit <deduction guide for Foo>
|-TemplateTypeParmDecl 0x5633ce6eac18 <line:1:11, col:20> col:20 referenced typename depth 0 index 0 T1
|-TemplateTypeParmDecl 0x5633ce6eacd8 <col:24, col:33> col:33 referenced typename depth 0 index 1 T2
|-CXXDeductionGuideDecl 0x5633ce70c678 <line:2:8> col:8 implicit <deduction guide for Foo> 'auto (T1, T2) -> Foo<T1, T2>'
| |-ParmVarDecl 0x5633ce70c588 <col:8> col:8 'T1'
| `-ParmVarDecl 0x5633ce70c608 <col:8> col:8 'T2'
`-CXXDeductionGuideDecl 0x5633ce70ce68 <col:8> col:8 implicit used <deduction guide for Foo> 'auto (int, int) -> Foo<int, int>' implicit_instantiation
|-TemplateArgument type 'int'
| `-BuiltinType 0x5633ce699230 'int'
|-TemplateArgument type 'int'
| `-BuiltinType 0x5633ce699230 'int'
|-ParmVarDecl 0x5633ce70cad8 <col:8> col:8 'int'
`-ParmVarDecl 0x5633ce70cb88 <col:8> col:8 'int'
```
We have issues:
- we don't have the aggregate deduction guide decl for the alias `A`, we should synthesize one from the Foo's `auto (T1, T2) -> Foo<T1, T2>`;
- the template argument deduction is performed on deduction guide for `Foo`, which should be performed on use this synthesized guide decl (the instantiation should not be performed on deduction guide for `A`);
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEl82O2zYUhZ-G3lx4QJGyKC288E_cbYEa7WRVUNKVxUYiDZFKZvr0BekfyXY84yRtCgS2RZPn3Hv4ZUxKa9VOI87JbEkYq80nVJowRmbriexdbbr5YWySm_J1vq0RKtM05ovSOyhMiaAsSA34Itt947_sQO52He6kQyix7AunjIZdr0q0T4SuCV0cXxN6_BceHbb7xi8ifOVe96hli7CNCFvB8MgI_3CYbl3XFw42xgARSzgMAgBsI3AR4cvRCAPHziNErIfPF85j4-cL349n2976xhdA-Np7E74KM8OES9UFyDCLiGVogl0YX_Z-ePXhdugrKWHx2xZIQtenAH_x-a2xaEhCQZsSLTTGfIJGfULCF2_kSsRquul1UNkeO_VCQF9mCecFCprHjPrYG6W9mCB8EUo-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