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".