This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44854] Improve diagnostic for missing member name or ';' in a struct
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Oct 2011 10:23:57 +0000
- Subject: [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct
- Auto-submitted: auto-generated
- References: <bug-44854-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44854
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #2 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2011-10-03 10:23:57 UTC ---
(In reply to comment #1)
> identifier is the same as member name. In fact I say GCC's diagnostic is more
> correct as ( can be there also.
I am sorry Andrew, but this way of reasoning is counter-intuitive. Can you
write?
struct foo { int (};
No, so talking about '(' doesn't make sense. And: "specifier-qualifier-list at
end of input" is equally bogus.
BTW, clang++ is neither perfect, and it makes a mess of error-recovery here.
/tmp/webcompile/_12636_0.cc:1:18: error: expected member name or ';' after
declaration specifiers
struct foo { int };
~~~ ^
/tmp/webcompile/_12636_0.cc:1:20: error: expected '}'
struct foo { int };
^
/tmp/webcompile/_12636_0.cc:1:12: note: to match this '{'
struct foo { int };
^
/tmp/webcompile/_12636_0.cc:1:20: error: expected ';' after struct
struct foo { int };
^
;
3 errors generated.
I guess it skips the '}' as the (invalid) member name, and consumes the ";" as
the end of the member declaration. Then, it notices that it needs a '}' and a
';'.
On the other hand, g++ is almost perfect:
test.cc:1:18: error: expected unqualified-id before â}â token
except for the legalese-speak "unqualified-id".