This is the mail archive of the gcc-patches@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]

regression on diagnosing unexpected declaration


:ADDPATCH c:

This regression is my fault. While fixing PR c/29062 I didn't consider
the following testcase.

void f(x)
{
  if (x > 1)
    int ret = 1; /* error: a label can only be part of a statement and
a declaration is not a statement */

}

Now I realise that the fix was far from optimal and very weak against
future changes in the C parser.

The fix is simple: move the relevant code to the moment where we just
finished parsing a label. The only caveat is that
c_parser_token_starts_declspecs() returns true for a label if the
label was defined as something else before. A testcase for this is in
the testsuite.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.

2007-11-28  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

 * c-parser (c_parser_statement_after_labels): Move error from here...
   (c_parser_label): ... to here. Check that the declaration is not
actually just another label.

testsuite/
  * gcc.dg/parse-decl-after-if.c: New.
  * gcc.dg/20031223-1.c: Adjust.

Attachment: fix-parse-decl-after-if.diff
Description: Text document


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