<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/147324>147324</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: Missing line and file in message error when ‘auto’ is used in a not permitted context (and bad diagnostic)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jonathanpoelen
</td>
</tr>
</table>
<pre>
With this code:
```cpp
int main()
{
struct A
{
void foo(auto x) {} // auto not permitted
};
}
```
And clang-18,19,20 or trunk and `-std=c++20` or `-std=c++23`:
> error: templates cannot be declared inside of a local class
No line number, no filename and refer to `template`.
With `-std=c++17`:
```
test.cpp:5:14: error: 'auto' not allowed in function prototype
5 | void foo(auto x) {}
| ^~~~
```
With gcc (same message for C++17 or C++20):
```
test.cpp: In function ‘int main()’:
test.cpp:5:14: error: ‘auto’ parameter not permitted in this context
5 | void foo(auto x) {}
| ^~~~
```
https://gcc.godbolt.org/z/5YGdh6Pnb
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VEuP5CYQ_jXVl9K0MH61Dz70YzrKIVFuUY4YyjYbDBbg2d0c5rdHuN29szOK5pSWpRZQVXyPKkQIerBELZQnKC87scTR-faLsyKOws6ODNld59T39k8dR4yjDiidIsiPwNavYrdPzjOwo7YRJ6Et8APwJp3XJwR2RAzRLzLicV08dhFfnFbYOwf8IJbo8BvwJp1DfUHgV-BXXPetiziTn3SMpLYiF8hP6x0XfAvlhuxoFUoj7PCUHYCfswb4mTN0HqNf7N8orEKo2FOICvKLBH4CfuIpP8V8PMlT5Qft_BnJe-chP2KkaTYiUkApbMLZESqSRnhSqG3QitD1KNA4KUwCFcKtzO8OjbaEdpk68sDPaB322pAVE60IPfXkMboE6H4PVGx_y19N-QA1q3-C-kaWSCHuk1P5sYT8mBUJ_oMH8DpJDbxe1RbGuK8rA-wXK6N2FmfvoovfZ9rcKxHqM37i4xaLj9jHD8rn19fXj96tvAYpEfghJCkmCkEMhL3zeL6zxB8LzlK7fUIZf33DBJ45HBg0h3ctu21vxT4R7F5jle2eibPwYqJI_uemTUJuA2QjfYv_r4RjjHNIJNYZGqTcD051zsS98wPw6z_Ar-Vfv6ix-sN2O9XmqskbsaM2q8usYVlTs93YVk1FRZ0VPWOHQrBG9H1TlZ0UhRCqrvhOt5zxktWszkpeZWzPi0z2fc5yUiJjlYKC0SS02RvzMqW7dzqEhdqsqHNe7IzoyIT1_eF8HVfgPD1Fvk0JT90yBCiY0SGGHyWijobaW3h-xN90CNoOt1lKU5NGKMl9b5vVMfw6kv0vz3TAJdw8Eu9s2-xKvZhqd0Kh0mKwLkQtgTe7xZv2ndw6jku3l24Cfk2ot7-n2bsvJCPw66pCAH7dhHhp-b8BAAD__5WJnF0">