Hi,

On 12/22/2014 07:55 PM, Jason Merrill wrote:
On 12/04/2014 07:51 AM, Paolo Carlini wrote:
Ideally, it would be nice to say something
more detailed about the invalid declaration, but that doesn't seem
trivial...

How about giving that error in cp_parser_init_declarator?

  /* An `=' or an `(', or an '{' in C++0x, indicates an initializer.  */
  if (token->type == CPP_EQ
      || token->type == CPP_OPEN_PAREN
      || token->type == CPP_OPEN_BRACE)
    {
      is_initialized = SD_INITIALIZED;
      initialization_kind = token->type;
      if (maybe_range_for_decl)
        *maybe_range_for_decl = error_mark_node;

Here.
That would be the place. But, at that point, it could still be a normal for loop, thus we can't just give an error. Assigning error_mark_node on the other hand is correct, because later, if we find the colon, we realize that the declaration is wrong because has an initializer. For the record, clang vs edg appear to handle this case differently: clang considers it a wrong for loop, edg a wrong range-based for loop. Humm...

Paolo.

Reply via email to