This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16663] Poor parse error recovery with mispelled type in function declaration
- From: "rui.maciel at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 11 Sep 2011 19:29:02 +0000
- Subject: [Bug c++/16663] Poor parse error recovery with mispelled type in function declaration
- Auto-submitted: auto-generated
- References: <bug-16663-4@http.gcc.gnu.org/bugzilla/>
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.