public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102773] New: Show fix-its for mispelled keywords like "templat" and "clas" and "typname"
@ 2021-10-15 11:50 redi at gcc dot gnu.org
2022-10-27 10:50 ` [Bug c++/102773] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-15 11:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102773
Bug ID: 102773
Summary: Show fix-its for mispelled keywords like "templat" and
"clas" and "typname"
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
templat<class T> void f(T) { }
template<clas T> void g(T) { }
template<typname T> void h(T) { }
int main()
{
f(1);
g(1);
h(1);
}
c.C:1:1: error: ‘templat’ does not name a type
1 | templat<class T> void f(T) { }
| ^~~~~~~
c.C:2:10: error: ‘clas’ has not been declared
2 | template<clas T> void g(T) { }
| ^~~~
c.C:2:23: error: variable or field ‘g’ declared void
2 | template<clas T> void g(T) { }
| ^
c.C:2:25: error: ‘T’ was not declared in this scope
2 | template<clas T> void g(T) { }
| ^
c.C:3:10: error: ‘typname’ has not been declared
3 | template<typname T> void h(T) { }
| ^~~~~~~
c.C:3:26: error: variable or field ‘h’ declared void
3 | template<typname T> void h(T) { }
| ^
c.C:3:28: error: ‘T’ was not declared in this scope
3 | template<typname T> void h(T) { }
| ^
c.C: In function ‘int main()’:
c.C:7:3: error: ‘f’ was not declared in this scope
7 | f(1);
| ^
c.C:8:3: error: ‘g’ was not declared in this scope
8 | g(1);
| ^
c.C:9:3: error: ‘h’ was not declared in this scope
9 | h(1);
| ^
This is too many errors for this code! There are only three small typos. We
should suggest fix-its for "templat" and "clas" and "typname" which are very
close to known keywords.
Clang prints even more errors, but it does include "did you mean ...?"
suggestions and fix-its:
c.C:1:1: error: no template named 'templat'
templat<class T> void f(T) { }
^
c.C:1:26: error: variable has incomplete type 'T'
templat<class T> void f(T) { }
^
c.C:1:15: note: forward declaration of 'T'
templat<class T> void f(T) { }
^
c.C:2:10: error: unknown type name 'clas'; did you mean 'class'?
template<clas T> void g(T) { }
^~~~
class
c.C:2:16: error: non-type template parameter has incomplete type 'class T'
template<clas T> void g(T) { }
^
c.C:1:15: note: forward declaration of 'T'
templat<class T> void f(T) { }
^
c.C:2:26: error: variable has incomplete type 'T'
template<clas T> void g(T) { }
^
c.C:1:15: note: forward declaration of 'T'
templat<class T> void f(T) { }
^
c.C:3:10: error: unknown type name 'typname'; did you mean 'typename'?
template<typname T> void h(T) { }
^~~~~~~
typename
c.C:3:18: error: expected a qualified name after 'typename'
template<typname T> void h(T) { }
^
c.C:3:19: error: non-type template parameter has incomplete type 'T'
template<typname T> void h(T) { }
^
c.C:1:15: note: forward declaration of 'T'
templat<class T> void f(T) { }
^
c.C:3:29: error: variable has incomplete type 'T'
template<typname T> void h(T) { }
^
c.C:1:15: note: forward declaration of 'T'
templat<class T> void f(T) { }
^
c.C:7:3: error: no matching function for call to 'f'
f(1);
^
c.C:1:23: note: candidate function not viable: no known conversion from 'int'
to 'T' for 1st argument
templat<class T> void f(T) { }
^
c.C:8:3: error: no matching function for call to 'g'
g(1);
^
c.C:2:23: note: candidate template ignored: couldn't infer template argument ''
template<clas T> void g(T) { }
^
c.C:9:3: error: no matching function for call to 'h'
h(1);
^
c.C:3:26: note: candidate template ignored: couldn't infer template argument ''
template<typname T> void h(T) { }
^
12 errors generated.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/102773] Show fix-its for mispelled keywords like "templat" and "clas" and "typname"
2021-10-15 11:50 [Bug c++/102773] New: Show fix-its for mispelled keywords like "templat" and "clas" and "typname" redi at gcc dot gnu.org
@ 2022-10-27 10:50 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-27 10:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102773
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-10-27
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Another example:
long i = reintepret_cast<long>((void*)0);
cast.C:1:10: error: ‘reintepret_cast’ was not declared in this scope
1 | long i = reintepret_cast<long>((void*)0);
| ^~~~~~~~~~~~~~~
cast.C:1:26: error: expected primary-expression before ‘long’
1 | long i = reintepret_cast<long>((void*)0);
| ^~~~
And this one with -std=c++20:
template<class T>
void
f(const void* v)
{
auto u = reintepret_cast<long>(v);
}
cast.C: In function 'void f(const void*)':
cast.C:5:12: error: there are no arguments to 'reintepret_cast' that depend on
a template parameter, so a declaration of 'reintepret_cast' must be available
[-fpermissive]
5 | auto u = reintepret_cast<long>(v);
| ^~~~~~~~~~~~~~~~~~~~~
cast.C:5:12: note: (if you use '-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-27 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 11:50 [Bug c++/102773] New: Show fix-its for mispelled keywords like "templat" and "clas" and "typname" redi at gcc dot gnu.org
2022-10-27 10:50 ` [Bug c++/102773] " redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).