This patch fixes the stride setting for cshift1; hence, it fixes gfortran.dg/optional_dim_3.f90.

Build and regtested on x86-64-linux - 13 failing tests remain.
OK?

Tobias
2012-07-15  Tobias Burnus  <bur...@net-b.de>

	* m4/cshift1.m4 (cshift1): Correctly set stride multiplier.
	* generated/cshift1_16.c: Regenerate.
	* generated/cshift1_4.c: Regenerate.
	* generated/cshift1_8.c: Regenerate.

Index: libgfortran/m4/cshift1.m4
===================================================================
--- libgfortran/m4/cshift1.m4	(Revision 189480)
+++ libgfortran/m4/cshift1.m4	(Arbeitskopie)
@@ -80,22 +80,18 @@ cshift1 (gfc_array_char * const restrict ret,
   if (ret->base_addr == NULL)
     {
       int i;
+      index_type sm, ext;
 
       ret->base_addr = xmalloc (size * arraysize);
       ret->offset = 0;
       ret->dtype = array->dtype;
+      sm = sizeof ('atype_name`);
+      ext = 1;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-	  index_type ext, sm;
-
+          sm *= ext;
           ext = GFC_DESCRIPTOR_EXTENT (array, i);
 
-          if (i == 0)
-            sm = 1;
-          else
-	    sm = GFC_DESCRIPTOR_EXTENT (ret, i-1)
-		 * GFC_DESCRIPTOR_SM (ret, i-1);
-
 	  GFC_DIMENSION_SET (ret->dim[i], 0, ext, sm);
         }
     }
Index: libgfortran/generated/cshift1_16.c
===================================================================
--- libgfortran/generated/cshift1_16.c	(Revision 189480)
+++ libgfortran/generated/cshift1_16.c	(Arbeitskopie)
@@ -79,22 +79,18 @@ cshift1 (gfc_array_char * const restrict ret,
   if (ret->base_addr == NULL)
     {
       int i;
+      index_type sm, ext;
 
       ret->base_addr = xmalloc (size * arraysize);
       ret->offset = 0;
       ret->dtype = array->dtype;
+      sm = sizeof (GFC_INTEGER_16);
+      ext = 1;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-	  index_type ext, sm;
-
+	  sm *= ext;
           ext = GFC_DESCRIPTOR_EXTENT (array, i);
 
-          if (i == 0)
-            sm = 1;
-          else
-	    sm = GFC_DESCRIPTOR_EXTENT (ret, i-1)
-		 * GFC_DESCRIPTOR_SM (ret, i-1);
-
 	  GFC_DIMENSION_SET (ret->dim[i], 0, ext, sm);
         }
     }
Index: libgfortran/generated/cshift1_4.c
===================================================================
--- libgfortran/generated/cshift1_4.c	(Revision 189480)
+++ libgfortran/generated/cshift1_4.c	(Arbeitskopie)
@@ -79,22 +79,18 @@ cshift1 (gfc_array_char * const restrict ret,
   if (ret->base_addr == NULL)
     {
       int i;
+      index_type sm, ext;
 
       ret->base_addr = xmalloc (size * arraysize);
       ret->offset = 0;
       ret->dtype = array->dtype;
+      sm = sizeof (GFC_INTEGER_4);
+      ext = 1;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-	  index_type ext, sm;
-
+	  sm *= ext;
           ext = GFC_DESCRIPTOR_EXTENT (array, i);
 
-          if (i == 0)
-            sm = 1;
-          else
-	    sm = GFC_DESCRIPTOR_EXTENT (ret, i-1)
-		 * GFC_DESCRIPTOR_SM (ret, i-1);
-
 	  GFC_DIMENSION_SET (ret->dim[i], 0, ext, sm);
         }
     }
Index: libgfortran/generated/cshift1_8.c
===================================================================
--- libgfortran/generated/cshift1_8.c	(Revision 189480)
+++ libgfortran/generated/cshift1_8.c	(Arbeitskopie)
@@ -79,22 +79,18 @@ cshift1 (gfc_array_char * const restrict ret,
   if (ret->base_addr == NULL)
     {
       int i;
+      index_type sm, ext;
 
       ret->base_addr = xmalloc (size * arraysize);
       ret->offset = 0;
       ret->dtype = array->dtype;
+      sm = sizeof (GFC_INTEGER_8);
+      ext = 1;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-	  index_type ext, sm;
-
+	  sm *= ext;
           ext = GFC_DESCRIPTOR_EXTENT (array, i);
 
-          if (i == 0)
-            sm = 1;
-          else
-	    sm = GFC_DESCRIPTOR_EXTENT (ret, i-1)
-		 * GFC_DESCRIPTOR_SM (ret, i-1);
-
 	  GFC_DIMENSION_SET (ret->dim[i], 0, ext, sm);
         }
     }

Reply via email to