re PR c/29062 (unclear diagnostic for declaration after label)

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

	PR c/29062
	* c-parser.c (c_parser_statement_after_labels): Error if a
	declaration is parsed after a label.
testsuite/
	* gcc.dg/20031223-1.c: Adjust error output.
	* gcc.dg/parse-decl-after-label.c: New.

From-SVN: r129873
This commit is contained in:
Manuel López-Ibáñez 2007-11-03 19:41:20 +00:00
parent 47c95bff6b
commit 847c8ce4d1
5 changed files with 39 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2007-11-03 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/29062
* c-parser.c (c_parser_statement_after_labels): Error if a
declaration is parsed after a label.
2007-11-03 Daniel Jacobowitz <dan@codesourcery.com>
PR debug/33921

View File

@ -3811,6 +3811,14 @@ c_parser_statement_after_labels (c_parser *parser)
break;
default:
expr_stmt:
if (c_parser_next_token_starts_declspecs (parser))
{
error ("a label can only be part of a statement and a declaration is not a statement");
c_parser_declaration_or_fndef (parser, /*fndef_ok*/ false,
/*nested*/ true, /*empty_ok*/ false,
/*start_attr_ok*/ true);
return;
}
stmt = c_finish_expr_stmt (c_parser_expression_conv (parser).value);
expect_semicolon:
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");

View File

@ -1,3 +1,9 @@
2007-11-03 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/29062
* gcc.dg/20031223-1.c: Adjust error output.
* gcc.dg/parse-decl-after-label.c: New.
2007-11-03 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/24685

View File

@ -7,5 +7,6 @@
void f ()
{
l: int; /* { dg-error "" } */
l: int; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" } */
/* { dg-warning "useless type name in empty declaration" "" { target *-*-* } 10 } */
}

View File

@ -0,0 +1,17 @@
/* PR 29062
{ dg-do compile }
{ dg-options "-fsyntax-only" }
*/
int f(x)
{
if (x > 1)
{
goto finish;
}
return x;
finish:
int ret = 1; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" } */
return ret;
}