re PR fortran/53148 (Incorrect intrinsic function parsing on labeled statements when...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 29 Apr 2012 07:12:03 +0000 (07:12 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 29 Apr 2012 07:12:03 +0000 (07:12 +0000)
2012-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/53148
* frontend-passes.c (create_var):  If the statement has a label,
put the label around the block.

2012-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/53148
* gfortran.dg/function_optimize_12.f90:  New test.

From-SVN: r186942

gcc/fortran/ChangeLog
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/function_optimize_12.f90 [new file with mode: 0644]

index f5ce12c..8d04904 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/53148
+       * frontend-passes.c (create_var):  If the statement has a label,
+       put the label around the block.
+
 2012-04-25  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52196
index b20dabb..92a3f8f 100644 (file)
@@ -271,6 +271,16 @@ create_var (gfc_expr * e)
       inserted_block->ext.block.assoc = NULL;
 
       ns->code = *current_code;
+
+      /* If the statement has a label,  make sure it is transferred to
+        the newly created block.  */
+
+      if ((*current_code)->here) 
+       {
+         inserted_block->here = (*current_code)->here;
+         (*current_code)->here = NULL;
+       }
+
       inserted_block->next = (*current_code)->next;
       changed_statement = &(inserted_block->ext.block.ns->code);
       (*current_code)->next = NULL;
index 3b3a1f6..a5e7cf2 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/53148
+       * gfortran.dg/function_optimize_12.f90:  New test.
+
 2012-04-29  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/53156
diff --git a/gcc/testsuite/gfortran.dg/function_optimize_12.f90 b/gcc/testsuite/gfortran.dg/function_optimize_12.f90
new file mode 100644 (file)
index 0000000..3c49add
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do run }
+! { dg-options "-ffrontend-optimize" }
+! PR 53148 - this used to cause wrong code because the label was
+! placed after the statement assigning the new variables.
+program main
+  integer :: n
+  double precision x
+  n = 3
+  goto 100
+100 x = dble(n) + dble(n)
+  if (x /= 6.d0) call abort
+end program main