diff mbox

[fortran,committed] Fix PR 53148

Message ID 4F9CEA44.1040208@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig April 29, 2012, 7:14 a.m. UTC
Hello world,

I have committed the attached patch as obvious as rev. 186942
after regression-testing.  Will also commit to 4.7 in a few
days.

	Thomas

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.
! { 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
diff mbox

Patch

Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 186549)
+++ frontend-passes.c	(Arbeitskopie)
@@ -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;