Note that the TemplateTypeParmDecl is the same in the class template decl and deduction guide. We seem to take a shortcurt and reuse the TemplateTypeParmDecl when synthesizing the deduction guide. Instead, we should clone one to make distinct template parameters for the deduction guide.
https://godbolt.org/z/ea8vzaoeP
```
template <typename T1> struct B {
B(T1);
};
B b(1);
```
The AST is:
```
|-ClassTemplateDecl 0xd400cf0 <<source>:1:1, line:3:1> line:1:31 B
| |-TemplateTypeParmDecl 0xd400b68 <col:11, col:20> col:20 referenced typename depth 0 index 0 T1
...
-FunctionTemplateDecl 0xd401680 <line:1:1, line:2:7> col:3 implicit <deduction guide for B>
| |-TemplateTypeParmDecl 0xd400b68 <line:1:11, col:20> col:20 referenced typename depth 0 index 0 T1
| |
```
Note that the `TemplateTypeParmDecl` is the same in the class template decl and deduction guide. We seem to take a shortcurt and reuse the `TemplateTypeParmDecl` when synthesizing the deduction guide. Instead, we should clone one to make distinct template parameters for the deduction guide.
https://godbolt.org/z/ea8vzaoeP
The AST is:
Note that the
TemplateTypeParmDecl
is the same in the class template decl and deduction guide. We seem to take a shortcurt and reuse theTemplateTypeParmDecl
when synthesizing the deduction guide. Instead, we should clone one to make distinct template parameters for the deduction guide.