This is the mail archive of the gcc@gcc.gnu.org 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: Range-based for in c++98


On 10/02/2010 01:50 PM, Rodrigo Rivas wrote:
I would change cp_parser_range_for to use cp_parser_decl_specifier_seq
> instead of cp_parser_type_specifier_seq and then wait to complain about
> defining a type until after we've seen the ':'.
I already tried that, but it didn't work. It seemed to me that it was
because it called cp_parser_commit_to_tentative_parse(), and if then I
wanted to roll-back the parsing of the range-for, I went badly. I had
to agree with Manuel that the tentative parsing is a bit messy...

Ah, yes. So we should share the parsing of the decl-specifier-seq with the C-style for loop, which allows us to avoid the tentative parsing.


Admittedly, this is not a "trailing_return_type", but AFAICT it has
exactly the same restrictions.

The restrictions are slightly different; in the case of a trailing return type a class-specifier is not one of the expansions, so we don't treat a { as beginning a class body. In the case of a type-specifier-seq, we do treat it as beginning a class body, but we give an error about it.


Jason


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