http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16663
Rui Maciel <rui.maciel at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rui.maciel at gmail dot com --- Comment #7 from Rui Maciel <rui.maciel at gmail dot com> 2011-09-11 19:29:02 UTC --- (In reply to comment #4) > In GCC 4.4 we have: > > pr16663.C:2: error: variable or field ‘Foo’ declared void > pr16663.C:2: error: ‘misspelled’ was not declared in this scope > pr16663.C:2: error: expected primary-expression before ‘char’ > pr16663.C:2: error: expected primary-expression before ‘bool’ > pr16663.C:2: error: expected primary-expression before ‘float’ > > This is not easy to fix since that statement can be a function declaration but > also a variable declaration and initialization. We try to parse tentatively > the > first case, fail, then we parse the second case and see that 'void' is not > allowed and that 'misspelled' is not declared. If 'void' is not allowed and 'misspelled' is not declared, then wouldn't it be better to recognize that case as an undeclared 'misspelled' instead of an impossible (or, at least, highly improbable) declaration of a variable of type void? As things stand, GCC outputs a cryptic error message that is based on the expectation that a variable being declared with type void is both correct and the expected behaviour, and this isn't helpful.