diff options
| author | Martin Nagy <nagy.martin@gmail.com> | 2009-04-27 10:48:50 +0200 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2009-07-18 05:30:10 +0000 |
| commit | 78798b4f946a37b1ffbbc6853765e479eca553e8 (patch) | |
| tree | d78f2b908a585aa74e7e4a5edcb0249cc6b3cdc0 /parse.c | |
| parent | 909d306e74e73a40aab10dcbe26261fb381a30b2 (diff) | |
| download | sparse-dev-78798b4f946a37b1ffbbc6853765e479eca553e8.tar.gz | |
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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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"); } |
