trans.c (gfc_finish_block, [...]): Build statement lists instead of compound expr...
authorPaul Brook <paul@codesourcery.com>
Thu, 3 Jun 2004 21:56:54 +0000 (21:56 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Thu, 3 Jun 2004 21:56:54 +0000 (21:56 +0000)
* trans.c (gfc_finish_block, gfc_add_expr_to_block): Build statement
lists instead of compound expr chains.
(gfc_trans_code): Annotate statement lists.

From-SVN: r82604

gcc/fortran/ChangeLog
gcc/fortran/trans.c

index fefddc2273e2b72ae333696992530f0a8e9875dd..3cb938c36af3a4fa931de9d0e5984064ee6b9813 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-03  Paul Brook  <paul@codesourcery.com>
+
+       * trans.c (gfc_finish_block, gfc_add_expr_to_block): Build statement
+       lists instead of compound expr chains.
+       (gfc_trans_code): Annotate statement lists.
+
 2004-06-03  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * trans-array.c: Fix spelling in comments.
index 6a42b03935e71608ead9b99ec4a799ecd1bcdd58..bb994a7f6dae0fb5717848f4c3d341eff4d1352b 100644 (file)
@@ -215,7 +215,10 @@ gfc_finish_block (stmtblock_t * stmtblock)
   tree expr;
   tree block;
 
-  expr = rationalize_compound_expr (stmtblock->head);
+  expr = stmtblock->head;
+  if (!expr)
+    expr = build_empty_stmt ();
+
   stmtblock->head = NULL_TREE;
 
   if (stmtblock->has_scope)
@@ -387,10 +390,23 @@ gfc_add_expr_to_block (stmtblock_t * block, tree expr)
   if (expr == NULL_TREE || IS_EMPTY_STMT (expr))
     return;
 
-  expr = fold (expr);
+  if (TREE_CODE (expr) != STATEMENT_LIST)
+    expr = fold (expr);
+
   if (block->head)
-    block->head = build_v (COMPOUND_EXPR, block->head, expr);
+    {
+      if (TREE_CODE (block->head) != STATEMENT_LIST)
+       {
+         tree tmp;
+
+         tmp = block->head;
+         block->head = NULL_TREE;
+         append_to_statement_list (tmp, &block->head);
+       }
+      append_to_statement_list (expr, &block->head);
+    }
   else
+    /* Don't bother creating a list if we only have a single statement.  */
     block->head = expr;
 }
 
@@ -592,7 +608,11 @@ gfc_trans_code (gfc_code * code)
 
       if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
        {
-         annotate_with_locus (res, input_location);
+         if (TREE_CODE (res) == STATEMENT_LIST)
+           annotate_all_with_locus (&res, input_location);
+         else
+           annotate_with_locus (res, input_location);
+
          /* Add the new statemment to the block.  */
          gfc_add_expr_to_block (&block, res);
        }