diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-17 15:17:01 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-17 19:04:25 -0800 |
commit | 132e0c466c4198445f8e327c291ab38fe79f6032 (patch) | |
tree | b9708ed3ca0f1f243054a9296031e7867a99b11f /expr.c | |
parent | 0beaca9548a524557d33d3c618e5ec586cf489d3 (diff) |
Fix sizeof with unparenthesized postfix or compound literal expression
Determining whether it is a typename or unparenthesized expression
requires consuming the '(', so we need to call postfixexpr/parseinit
ourselves.
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -603,13 +603,20 @@ unaryexpr(struct scope *s) next(); if (consume(TLPAREN)) { t = typename(s); - if (!t) { + if (t) { + expect(TRPAREN, "after type name"); + /* might be part of a compound literal */ + if (op == TSIZEOF && tok.kind == TLBRACE) + parseinit(s, t); + } else { e = expr(s); + expect(TRPAREN, "after expression"); + if (op == TSIZEOF) + e = postfixexpr(s, e); if (e->flags & EXPRFLAG_DECAYED) e = e->unary.base; t = e->type; } - expect(TRPAREN, "after type name"); } else if (op == TSIZEOF) { e = unaryexpr(s); if (e->flags & EXPRFLAG_DECAYED) |