Skip to contentSkip to conversation

Fix __label__ handling

PATCH Al Viro 1 participant 1 message Mar 9, 2009 Sparse checker

lore
Share & tools
lore

Al Viro

author
#0 lore raw

a) __label__ in gcc is not a type, it's a statement. Accepted in the beginning of compound-statement, has form __label__ ident-list;
b) instead of crapping into NS_SYMBOL namespace (and consequent shadowing issues), reassign the namespace to NS_LABEL after we'd bound it. We'll get block scope and label namespace, i.e. what we get in gcc.
c) MOD_LABEL can be dropped now.

---
 gdbhelpers               |    3 --
 ident-list.h             |    1 +
 parse.c                  |   55 ++++++++++++++++++++++-----------------------
 symbol.h                 |    1 -
 validation/label-scope.c |   12 ++++++++++
 5 files changed, 40 insertions(+), 32 deletions(-)
 create mode 100644 validation/label-scope.c
gdbhelpers +0 -3
index 7223ffd..e28417a 100644
@@ -146,9 +146,6 @@ define gdb_show_ctype
 	if ($arg0->modifiers & MOD_TOPLEVEL)
 		printf "MOD_TOPLEVEL "
 	end
-	if ($arg0->modifiers & MOD_LABEL)
-		printf "MOD_LABEL "
-	end
 	if ($arg0->modifiers & MOD_ASSIGNED)
 		printf "MOD_ASSIGNED "
 	end
ident-list.h +1 -0
index e22084e..29ddeca 100644
@@ -31,6 +31,7 @@ IDENT(alignof); IDENT_RESERVED(__alignof); IDENT_RESERVED(__alignof__);
 IDENT_RESERVED(__sizeof_ptr__);
 IDENT_RESERVED(__builtin_types_compatible_p);
 IDENT_RESERVED(__builtin_offsetof);
+IDENT_RESERVED(__label__);
 
 /* Attribute names */
 IDENT(packed); IDENT(__packed__);
parse.c +27 -28

82 lines not on this page · raw message

symbol.h +0 -1
index f9944bf..f58c80a 100644
@@ -207,7 +207,6 @@ struct symbol {
 #define MOD_ACCESSED	0x400000
 #define MOD_TOPLEVEL	0x800000	// scoping..
 
-#define MOD_LABEL	0x1000000
 #define MOD_ASSIGNED	0x2000000
 #define MOD_TYPE	0x4000000
 #define MOD_SAFE	0x8000000	// non-null/non-trapping pointer
validation/label-scope.c new file +12 -0
new file mode 100644
index 0000000..7af3d91
@@ -0,0 +1,12 @@
+static int f(int n)
+{
+	__label__ n;
+n:	return n;
+}
+static int g(int n)
+{
+n:	return n;
+}
+/*
+ * check-name: __label__ scope
+ */
Signature · 1 line
1.5.6.5