aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 12:01:00 -0700
committerChristopher Li <sparse@chrisli.org>2014-04-03 12:03:52 -0700
commit38d1124ec5cd10e117e320e25a55305dca0899b6 (patch)
treeeec5762fff8de734a664877d51a08eb03ac0bc58 /evaluate.c
parent42ebe4166c52a0c4cb8b50ab488374ac5c92ff2b (diff)
downloadsparse-dev-38d1124ec5cd10e117e320e25a55305dca0899b6.tar.gz
Fix error at anoymous unions
Ok, this fixes the warning, but we seem to still mess up the actual initializer. It looks like some later phase gets the offset wrong, so when we lay things out in memory, we'll put things at offset zero (which is right for your test-case, but not if there was something before that anonymous union). Regardless, that only matters for real code generation, not for using sparse as a semantic checker, so this patch is correct and is an improvement. Reported-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/evaluate.c b/evaluate.c
index b86b21bf..7ce8c555 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2209,17 +2209,6 @@ static int evaluate_arguments(struct symbol *f, struct symbol *fn, struct expres
return 1;
}
-static struct symbol *find_struct_ident(struct symbol *ctype, struct ident *ident)
-{
- struct symbol *sym;
-
- FOR_EACH_PTR(ctype->symbol_list, sym) {
- if (sym->ident == ident)
- return sym;
- } END_FOR_EACH_PTR(sym);
- return NULL;
-}
-
static void convert_index(struct expression *e)
{
struct expression *child = e->idx_expression;
@@ -2328,11 +2317,12 @@ static struct expression *check_designators(struct expression *e,
}
e = e->idx_expression;
} else if (e->type == EXPR_IDENTIFIER) {
+ int offset = 0;
if (ctype->type != SYM_STRUCT && ctype->type != SYM_UNION) {
err = "field name not in struct or union";
break;
}
- ctype = find_struct_ident(ctype, e->expr_ident);
+ ctype = find_identifier(e->expr_ident, ctype->symbol_list, &offset);
if (!ctype) {
err = "unknown field name in";
break;