X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast.c;h=ac8caeb63bb3607af5832a2eb63bed99a1efd457;hb=18a1fc944eceff05ebdc0f6baab33db346cdf0a8;hp=1deb7bf6a78b8e1e71cd686f360909b13ea534ca;hpb=1f36beb621b353950b2d73415e08ccdba815abea;p=cparser diff --git a/ast.c b/ast.c index 1deb7bf..ac8caeb 100644 --- a/ast.c +++ b/ast.c @@ -1085,22 +1085,17 @@ static void print_do_while_statement(const do_while_statement_t *statement) static void print_for_statement(const for_statement_t *statement) { fputs("for (", out); - entity_t *entity = statement->scope.entities; - while (entity != NULL && is_generated_entity(entity)) - entity = entity->base.next; - - if (entity != NULL) { - assert(statement->initialisation == NULL); - assert(is_declaration(entity)); - print_declaration(entity); - if (entity->base.next != NULL) { - panic("multiple declarations in for statement not supported yet"); - } + if (statement->initialisation != NULL) { + print_expression(statement->initialisation); + fputc(';', out); } else { - if (statement->initialisation) { - print_expression(statement->initialisation); + entity_t const *entity = statement->scope.entities; + for (; entity != NULL; entity = entity->base.next) { + if (is_generated_entity(entity)) + continue; + /* FIXME display of multiple declarations is wrong */ + print_declaration(entity); } - fputc(';', out); } if (statement->condition != NULL) { fputc(' ', out);