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]

[C++ Patch] PR 32108 (take2)


Hi all, hi Mark,

this is the amended patch according to your indications (well, you
almost did it yourself, thanks for the help!)

Tested x86_64-linux, Ok for mainline?

Paolo.

///////////////
cp/
2007-07-29  Paolo Carlini  <pcarlini@suse.de>

	PR c++/32108
	* semantics.c (finish_label_stmt): Reject the __label__
	extension outside function scopes.

testsuite/
2007-07-29  Paolo Carlini  <pcarlini@suse.de>

	PR c++/32108
	* g++.dg/ext/label6.C: New.

Index: testsuite/g++.dg/ext/label6.C
===================================================================
--- testsuite/g++.dg/ext/label6.C	(revision 0)
+++ testsuite/g++.dg/ext/label6.C	(revision 0)
@@ -0,0 +1,3 @@
+// PR c++/32108
+
+__label__ L; // { dg-error "function scopes" }
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 127042)
+++ cp/semantics.c	(working copy)
@@ -1343,8 +1343,13 @@ finish_label_stmt (tree name)
 void
 finish_label_decl (tree name)
 {
-  tree decl = declare_local_label (name);
-  add_decl_expr (decl);
+  if (!at_function_scope_p ())
+    {
+      error ("__label__ declarations are only allowed in function scopes");
+      return;
+    }
+
+  add_decl_expr (declare_local_label (name));
 }
 
 /* When DECL goes out of scope, make sure that CLEANUP is executed.  */

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