aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Nagy <nagy.martin@gmail.com>2009-04-27 10:48:50 +0200
committerChristopher Li <sparse@chrisli.org>2009-07-18 05:30:10 +0000
commit78798b4f946a37b1ffbbc6853765e479eca553e8 (patch)
treed78f2b908a585aa74e7e4a5edcb0249cc6b3cdc0 /parse.c
parentAdd missing checks for Waddress-space (diff)
downloadsparse-78798b4f946a37b1ffbbc6853765e479eca553e8.tar.gz
sparse-78798b4f946a37b1ffbbc6853765e479eca553e8.tar.bz2
sparse-78798b4f946a37b1ffbbc6853765e479eca553e8.zip
Print an error if typeof() lacks an argument
We weren't checking if the initializer isn't NULL, which caused sparse to segfault later on when performing lazy evaluation in classify_type(). Signed-off-by: Martin Nagy <nagy.martin@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 9662122..e7dbeb9 100644
--- a/parse.c
+++ b/parse.c
@@ -928,8 +928,12 @@ static struct token *typeof_specifier(struct token *token, struct decl_state *ct
token = parse_expression(token->next, &typeof_sym->initializer);
typeof_sym->endpos = token->pos;
+ if (!typeof_sym->initializer) {
+ sparse_error(token->pos, "expected expression after the '(' token");
+ typeof_sym = &bad_ctype;
+ }
ctx->ctype.base_type = typeof_sym;
- }
+ }
return expect(token, ')', "after typeof");
}