aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Li <sparse@chrisli.org>2007-10-19 14:08:16 -0700
committerJosh Triplett <josh@freedesktop.org>2007-10-20 19:15:00 -0700
commit8d79ef8142b754061d6ef26a3ba29ba503a3621d (patch)
treec5d369ae41f1d59155925fc2d214200d5fe4c5b2
parentfa7d792f66cf02b86dd834d06b267ec66ddfe700 (diff)
downloadsparse-8d79ef8142b754061d6ef26a3ba29ba503a3621d.tar.gz
sparse-8d79ef8142b754061d6ef26a3ba29ba503a3621d.tar.xz
sparse-8d79ef8142b754061d6ef26a3ba29ba503a3621d.zip
Perform local label lookup
This patch fix the sparse breakage triggered by rcu_read_lock() lockdep annotations. Now sparse look up the local label in symbol node name space as well, just like looking up a normal symbol node. Now a lable symbol can be both type SYM_LABEL or SYM_NODE with MOD_LABEL. Singed-Off-By: Christopher Li <sparse@chrisli.org>
-rw-r--r--parse.c13
-rw-r--r--validation/local-label.c8
2 files changed, 21 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index f452042..47b5204 100644
--- a/parse.c
+++ b/parse.c
@@ -459,6 +459,16 @@ static struct symbol *lookup_or_create_symbol(enum namespace ns, enum type type,
return sym;
}
+static struct symbol * local_label(struct token *token)
+{
+ struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL);
+
+ if (sym && sym->ctype.modifiers & MOD_LABEL)
+ return sym;
+
+ return NULL;
+}
+
/*
* NOTE! NS_LABEL is not just a different namespace,
* it also ends up using function scope instead of the
@@ -466,6 +476,9 @@ static struct symbol *lookup_or_create_symbol(enum namespace ns, enum type type,
*/
struct symbol *label_symbol(struct token *token)
{
+ struct symbol *sym = local_label(token);
+ if (sym)
+ return sym;
return lookup_or_create_symbol(NS_LABEL, SYM_LABEL, token);
}
diff --git a/validation/local-label.c b/validation/local-label.c
new file mode 100644
index 0000000..c2d0cb7
--- /dev/null
+++ b/validation/local-label.c
@@ -0,0 +1,8 @@
+void f(unsigned long ip);
+static void g(void)
+{
+ if (1) {
+ f(({ __label__ x; x: (unsigned long)&&x; }));
+ }
+ f(({ __label__ x; x: (unsigned long)&&x; }));
+}