On 10/04/2010 10:59 AM, Rodrigo Rivas wrote:
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.

Well, the net effect is the same: the tentative parsing is aborted.
Then the C-style loop for parses the code, and it is this that prints
the error message if needed.

True, it's just a question of what error you get from something like

for (struct A {} a : vector<A>());

that is, is this parsed as a range-based for loop which invalidly defines a type, or as syntax nonsense? Either way you get standard-conforming behavior, but the former gives a more useful diagnostic.

I think the right answer is, as you say, to split up cp_parser_simple_declaration so we can share the cp_parser_decl_specifier_seq call between the two cases.

Jason

Reply via email to