Patchwork [Fortran-dev] Fix cshift1

login
register
mail settings
Submitter Tobias Burnus
Date July 15, 2012, 7 a.m.
Message ID <50026A8C.3070805@net-b.de>
Download mbox | patch
Permalink /patch/171049/
State New
Headers show

Comments

Tobias Burnus - July 15, 2012, 7 a.m.
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
Thomas Koenig - July 15, 2012, 8:52 a.m.
Hi Tobias,

> 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?

OK. Thanks for the patch!

	Thomas

Patch

2012-07-15  Tobias Burnus  <burnus@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);
         }
     }