summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/parse.c b/parse.c
index 0963095..fe17515 100644
--- a/parse.c
+++ b/parse.c
@@ -2812,7 +2812,9 @@ static Node *new_inc_dec(Node *node, Token *tok, int addend) {
// | "->" ident
// | "++"
// | "--"
+// fixed per: https://github.com/rui314/chibicc/issues/84
static Node *postfix(Token **rest, Token *tok) {
+ Node *node = 0;
if (equal(tok, "(") && is_typename(tok->next)) {
// Compound literal
Token *start = tok;
@@ -2821,18 +2823,18 @@ static Node *postfix(Token **rest, Token *tok) {
if (scope->next == NULL) {
Obj *var = new_anon_gvar(ty);
- gvar_initializer(rest, tok, var);
- return new_var_node(var, start);
+ gvar_initializer(&tok, tok, var);
+ node = new_var_node(var, start);
+ } else {
+ Obj *var = new_lvar("", ty);
+ Node *lhs = lvar_initializer(&tok, tok, var);
+ Node *rhs = new_var_node(var, tok);
+ node = new_binary(ND_COMMA, lhs, rhs, start);
}
-
- Obj *var = new_lvar("", ty);
- Node *lhs = lvar_initializer(rest, tok, var);
- Node *rhs = new_var_node(var, tok);
- return new_binary(ND_COMMA, lhs, rhs, start);
+ } else {
+ node = primary(&tok, tok);
}
- Node *node = primary(&tok, tok);
-
for (;;) {
if (equal(tok, "(")) {
node = funcall(&tok, tok->next, node);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback