http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55613
Bug #: 55613 Summary: Better warning for reference to struct type Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: rui.mac...@gmail.com Consider the following code: <code> struct Foo { int i; }; int main(void) { Foo foo; return 0; } </code> When compiled with gcc 4.6.3, the following error message is displayed: <message> main.c: In function ‘main’: main.c:8:2: error: unknown type name ‘Foo’ </message> The problem with this code is that Foo isn't preceded by the keyword "struct". Yet, as the compiler only returns a vague message about Foo being an unknown type name, it may mislead the programmer into assuming that the problem might lie somewhere else, such as a typo somewhere, particularly if the code contains a significant number of typedef structs. A significantly better way to handle this error is to warn that the "struct" keyword is missing. This happens to be the way other compilers, such as clang, handle this error. The following is clang's error message for this scenario: <message> main.c:8:2: error: must use 'struct' tag to refer to type 'Foo' Foo foo; ^ struct 1 error generated. </message> It would be great if gcc improved its error diagnostics for this error.