diff options
| -rw-r--r-- | parse.c | 6 | ||||
| -rw-r--r-- | validation/bad-typeof.c | 14 |
2 files changed, 19 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"); } diff --git a/validation/bad-typeof.c b/validation/bad-typeof.c new file mode 100644 index 00000000..90c3e424 --- /dev/null +++ b/validation/bad-typeof.c @@ -0,0 +1,14 @@ +static int fun(void) +{ + typeof() a; + int b; + + a = b; +} +/* + * check-name: Bad typeof syntax segfault + * + * check-error-start +bad-typeof.c:3:16: error: expected expression after the '(' token + * check-error-end + */ |
