Better show something (syntactically invalid) when printing a for-statement with...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 21 Dec 2008 16:54:16 +0000 (16:54 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sun, 21 Dec 2008 16:54:16 +0000 (16:54 +0000)
[r24838]

ast.c

diff --git a/ast.c b/ast.c
index 1deb7bf..ac8caeb 100644 (file)
--- 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);