summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2017-01-24 09:45:12 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2017-01-24 10:00:13 +0100
commit0cc43ed4bb4d475728583eadcf9e9726682a838b (patch)
tree25981dd04e2aa4ea5616bc2d6a65c8a9cd19f04f /src
parentb9a11e627a3c506620450ffdd1a11f71938e2566 (diff)
Allow statement expressions ending in a label containing an expression statement to have this expression as result.
Technically ({ bla: 0; }) does not end in an expression statement, but in a label statement. Due to an implementation detail in GCC (labels do not have an inner statement, but their inner statement is made their successor) the statement expression does end in an expression statement. This fixes C/gnu99/stmtexpr.c.
Diffstat (limited to 'src')
-rw-r--r--src/parser/parser.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/parser/parser.c b/src/parser/parser.c
index 3c652a0..23cf594 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -6245,8 +6245,12 @@ static expression_t *get_statement_expression_last(
statement_t *const stmt = expr->statement;
assert(stmt->kind == STATEMENT_COMPOUND);
for (statement_t *s = stmt->compound.statements; s; s = s->base.next) {
- if (!s->base.next)
+ if (!s->base.next) {
+ while (s->kind == STATEMENT_LABEL) {
+ s = s->label.statement;
+ }
return s->kind == STATEMENT_EXPRESSION ? s->expression.expression : NULL;
+ }
}
return NULL;
}