This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to remove deprecated labels at end of compound statementsextension
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Jan 2004 20:05:18 +0000 (UTC)
- Subject: Patch to remove deprecated labels at end of compound statementsextension
This patch removes an undocumented extension (labels at ends of
compound statements without the required null statement) that has had
a mandatory deprecation pedwarn since 3.0 (and probably should have
been removed earlier). There's scope for simplifying the grammar and
making it follow the standard more closely, but turning the pedwarn
into an error seems the safest at this development stage.
Bootstrapped with no regressions on i686-pc-linux-gnu. I'll apply
this to mainline shortly unless anyone wishes to make any late
objections to removing this extension in 3.4.
2004-01-13 Joseph S. Myers <jsm@polyomino.org.uk>
* c-parse.in (stmts_and_decls): Make label at end of compound
statement a hard error.
testsuite:
2004-01-13 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/label-compound-stmt-1.c: New test.
* gcc.c-torture/compile/950922-1.c,
gcc.c-torture/compile/20000211-3.c,
gcc.c-torture/compile/20000518-1.c,
gcc.c-torture/compile/20021108-1.c: Avoid labels at and of
compound statements.
--- GCC/gcc/c-parse.in.orig 2003-12-17 00:10:26.000000000 +0000
+++ GCC/gcc/c-parse.in 2004-01-12 21:42:24.000000000 +0000
@@ -2001,7 +2001,7 @@ stmts_and_decls:
| lineno_stmt_decl_or_labels_ending_decl
| lineno_stmt_decl_or_labels_ending_label
{
- pedwarn ("deprecated use of label at end of compound statement");
+ error ("label at end of compound statement");
}
| lineno_stmt_decl_or_labels_ending_error
;
--- GCC/gcc/testsuite/gcc.dg/label-compound-stmt-1.c 2002-08-26 16:21:36.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/label-compound-stmt-1.c 2004-01-12 21:45:41.000000000 +0000
@@ -0,0 +1,7 @@
+/* Test that labels at ends of compound statements are hard errors. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void f(void) { g: } /* { dg-bogus "warning" "warning in place of error" } */
+/* { dg-error "label|parse|syntax" "label at end of compound statement" { target *-*-* } 6 } */
--- GCC/gcc/testsuite/gcc.c-torture/compile/950922-1.c.orig 1998-12-16 22:09:41.000000000 +0000
+++ GCC/gcc/testsuite/gcc.c-torture/compile/950922-1.c 2004-01-13 16:55:15.000000000 +0000
@@ -40,7 +40,7 @@
nosign:
if (_uquad != 0 || prec != 0);
break;
- default:
+ default:;
}
if ((f & 0x100) == 0) {
} else {
@@ -64,5 +64,5 @@
}
}
- error:
+ error:;
}
--- GCC/gcc/testsuite/gcc.c-torture/compile/20000211-3.c.orig 2000-02-11 22:26:41.000000000 +0000
+++ GCC/gcc/testsuite/gcc.c-torture/compile/20000211-3.c 2004-01-13 16:53:56.000000000 +0000
@@ -3,7 +3,7 @@
{
switch(x) {
default:
- mumble:
+ mumble:;
}
}
--- GCC/gcc/testsuite/gcc.c-torture/compile/20000518-1.c.orig 2000-05-18 22:03:16.000000000 +0000
+++ GCC/gcc/testsuite/gcc.c-torture/compile/20000518-1.c 2004-01-13 16:54:13.000000000 +0000
@@ -6,7 +6,7 @@
callit1(&&l1);
-l1:
+l1:;
}
--- GCC/gcc/testsuite/gcc.c-torture/compile/20021108-1.c.orig 2002-11-08 11:58:53.000000000 +0000
+++ GCC/gcc/testsuite/gcc.c-torture/compile/20021108-1.c 2004-01-13 16:54:23.000000000 +0000
@@ -3,5 +3,5 @@
{
l1:
return &&l1-&&l2;
-l2:
+l2:;
}
--- changes.html.orig 2004-01-07 22:18:32.000000000 +0000
+++ changes.html 2004-01-12 21:48:35.000000000 +0000
@@ -201,6 +201,9 @@
a correct implementation of <code>#import</code> and
<code>#pragma once</code>.
These two directives have therefore been un-deprecated.</li>
+ <li>The undocumented extension that allowed C programs to have a
+ label at the end of a compound statement, which has been
+ deprecated since GCC 3.0, has been removed.</li>
<li>The cast-as-lvalue extension has been removed for C++ and
deprecated for C and Objective-C. In particular,
code like this:
--
Joseph S. Myers
jsm@polyomino.org.uk