aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-07-29 11:53:47 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:24 -0700
commit3cbd300235d64123ba26b1acaf3ed68807ed523d (patch)
treeceb1b850778022a2b322e68f2ce126ca5f3ea094 /expression.c
parent07636c9f3a029aae73250ec786426ae6645d0cf3 (diff)
downloadsparse-dev-3cbd300235d64123ba26b1acaf3ed68807ed523d.tar.gz
Make sizeof understand the C99 "sizeof typed initializer" syntax.
Also fix the type return of initializer evaluation, so that we get the right size in the right place. Add the necessary lines to parse the thing too.
Diffstat (limited to 'expression.c')
-rw-r--r--expression.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/expression.c b/expression.c
index 46ed9a34..98c64ec6 100644
--- a/expression.c
+++ b/expression.c
@@ -400,7 +400,18 @@ static struct token *unary_expression(struct token *token, struct expression **t
if (!match_op(token, '(') || !lookup_type(token->next))
return unary_expression(token, &sizeof_ex->cast_expression);
token = typename(token->next, &sizeof_ex->cast_type);
- return expect(token, ')', "at end of sizeof type-name");
+
+ if (!match_op(token, ')'))
+ return expect(token, ')', "at end of sizeof type-name");
+
+ token = token->next;
+ /*
+ * C99 ambiguity: the typename might have been the beginning
+ * of a typed initializer expression..
+ */
+ if (match_op(token, '{'))
+ token = initializer(&sizeof_ex->cast_expression, token);
+ return token;
} else if (token->ident == &__alignof___ident) {
struct expression *alignof_ex
= alloc_expression(token->pos, EXPR_ALIGNOF);