This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix cp_parser_enum_specifier (PR c++/38021)

Jakub Jelinek wrote:

> 2008-11-05  Jakub Jelinek  <>
> 	PR c++/38021
> 	* parser.c (cp_parser_enum_specifier): Don't return if
> 	type specifier is errorneous.


> 	* g++.dg/cpp0x/enum1.C: New test.

I think that your patch means that we'll (eventually) abort the
tentative parse and return after seeing something like "enum x : 3".
But, once we see the ":" we can commit to this being an enum-specifier;
there's no other reasonable interpretation of what the user meant.

The reason that this function delays committing is that we don't know if
we're looking at "enum X" or "enum X { ... " when this function is
called.  The former is not an enum-specifier, but rather an

This comment:

  /* Caller guarantees that the current token is 'enum', an identifier

     possibly follows, and the token after that is an opening brace.

     If we don't have an identifier, fabricate an anonymous name for

     the enumeration being defined.  */

is, AFAICT, false.  The caller is cp_parser_type_specifier, and I don't
see those kinds of checks.

But, when we see the colon, or the C++0x class/struct keyword, we can
commit.  "enum struct X" is only part of a C++0x enum-specifier, and so
is "enum X : ".

So, I think the function should be reworked in that way.


Mark Mitchell
(650) 331-3385 x713

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]