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.