-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostics for template keywords showing up inside local classes aren't good #17959
Comments
This diagnostic is bad in the non-local-class case too. Something like non-static data member 'i' cannot be declared as a template would be better, to suggest that maybe the 'static' keyword is missing. |
@llvm/issue-subscribers-clang-frontend Author: None (991901f3-cc14-4404-b340-165691b62a58)
| | |
| --- | --- |
| Bugzilla Link | [17585](https://llvm.org/bz17585) |
| Version | unspecified |
| OS | Linux |
| CC | @DougGregor,@zygoloid |
Extended Descriptionconsider: void foo() {
template <typename> int i;
} we issue: error: expected expression gcc provides a better error: error: a template declaration cannot appear at block scope another case: void foo() {
struct S { template <typename> int i; };
} we issue: error: member 'i' declared as a template gcc provides: invalid declaration of member template in local class These plain english messages are very nice, we should do something similar. |
It turns out `SemaTemplate` handles this type of diagnostic already, however when template gets encountered, it never gets parsed as a possible statement or declaration, only as an expression. Fixes llvm#17959.
It turns out `SemaTemplate` handles this type of diagnostic already, however when template gets encountered, it never gets parsed as a possible statement or declaration, only as an expression. Fixes #17959.
Extended Description
consider:
we issue:
error: expected expression
gcc provides a better error:
error: a template declaration cannot appear at block scope
another case:
we issue:
error: member 'i' declared as a template
gcc provides:
invalid declaration of member template in local class
These plain english messages are very nice, we should do something similar.
The text was updated successfully, but these errors were encountered: