<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/155709>155709</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang includes implicit template arguments in constructor and destructor names for class templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
mizvekov
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mizvekov
</td>
</tr>
</table>
<pre>
Simple repro: https://compiler-explorer.com/z/fWz4qWddT
```C++
template <class T> struct A {
A() { return 0; }
};
template <class> struct B {
B() { return 0; }
};
```
Produces:
```
<source>:2:9: error: constructor 'A<T>' should not return a value [-Wreturn-mismatch]
2 | A() { return 0; }
| ^ ~
<source>:6:9: error: constructor 'B<type-parameter-0-0>' should not return a value [-Wreturn-mismatch]
6 | B() { return 0; }
```
This is specially egregious when the template parameter is anonymous.
This happens because the default printing policy includes printing the implicit template arguments for injected class names.
The same kind of problem also applies whenever the injected class type, or the record type produced from its instantiation, is printed in diagnostics.
In general, the default policy should be oriented towards printing the type as written. We can still include these extra details when printing the 'aka' in diagnostics though.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVMGO4ygQ_Rp8KSVyII7bBx-S9ETa20rbUp8xVOzaxuAFnJ70Yb99he10JjPS9kobIQVD1eO9qgcyBGotYs2KA-O8p48LvrkL45wVz5kcY-d8fVvNGqev9R_UDwbB4-AdE3voYhwCE3vGT4yflOsHMuhX-H0wzqNfK9czfvpg_HR-_dj-9ar1C8v3aezyeRwZP6SR7yP2g5ERgYmjMjIEeGHiG4ToRxVhD6xMUQB7xp8Yr9I3eIyjt5AzcQBWPifg8pmJw3zIL4g_4B0-8Q7_Ee_GeMb-3Ts9KpzE_7QpjsGNXiET35jYcyb2VaoVeu98mihnZxLOA-NlSkhKGS8hdG40GqyLNyoSLtKMCKw4rF7ntVVPoZdRdax4nhQAcGDlEb6qDUy_OXKZF9_myd-_Et99RfzAxDF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