points to C and B's is NULL. */
struct gfc_common_head* common_head;
+ /* Make sure initialization code is generated in the correct order. */
+ int decl_order;
+
gfc_namelist *namelist, *namelist_tail;
/* The tlink field is used in the front end to carry the module
minit ("_dtio_unformatted_write", DTIO_WUF),
};
+/* This is to make sure the backend generates setup code in the correct
+ order. */
+static int next_decl_order = 1;
gfc_namespace *gfc_current_ns;
gfc_namespace *gfc_global_ns_list;
return;
sym->attr.referenced = 1;
+
+ /* Remember the declaration order. */
+ sym->decl_order = next_decl_order++;
}
static bool
decl_order (gfc_symbol *sym1, gfc_symbol *sym2)
{
- if (sym1->declared_at.lb->location > sym2->declared_at.lb->location)
+ if (sym1->decl_order > sym2->decl_order)
return true;
else
return false;
--- /dev/null
+! { dg-do run }
+!
+! Fix a regression caused by the fix for PR59104.
+!
+! Contributed by Harald Anlauf <anlauf@gcc.gnu.org>
+!
+program p
+ implicit none
+ integer, parameter :: nx = 64, ny = 32
+ real :: x(nx,ny), s(nx/2,ny), d(nx/2,ny)
+
+ s = 0.0
+ d = 0.0
+ call sub (x,s,d)
+ if (sum(s) .ne. 256) stop 1
+ if (sum(d) .ne. 256) stop 2 ! Stopped with sum(d) == 0.
+contains
+ subroutine sub (v, w, d)
+ real, intent(in) :: v(:,:)
+ real, intent(out), dimension (size (v,dim=1)/4,size (v,dim=2)/2) :: w, d
+ w = 1.0
+ d = 1.0
+ if (any (shape (w) .ne. [nx/4, ny/2])) stop 3
+ if (any (shape (d) .ne. [nx/4, ny/2])) print *, shape (d) ! Printed "0 0" here
+ end subroutine sub
+end