This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran, committed] PR 43931 - coarray patch 10/n: Fix rank index for array descriptor type


Committed as obvious.

The array descriptor type is cached and thus re-used. In a previous
patch (8/n), I forgot to include the corank in the index and thus the
wrong type might be returned, which is fixed by this patch.
Additionally, there is no point in separating the rank and corank in the
shown name.

Bootstrapped and and regtested and committed as Rev.158941

Tobias
2010-04-30  Tobias Burnus  Mburnus@net-b.de>

	PR fortran/18918
	PR fortran/43931
	*  trans-types.c (gfc_get_array_descriptor_base): Fix index
	calculation for array descriptor types.

2010-04-30  Tobias Burnus  Mburnus@net-b.de>

	PR fortran/18918
	PR fortran/43931
	* gfortran.dg/coarray_13.f90: New test.

Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c	(revision 158929)
+++ gcc/fortran/trans-types.c	(working copy)
@@ -1542,7 +1542,7 @@ gfc_get_array_descriptor_base (int dimen
 {
   tree fat_type, fieldlist, decl, arraytype;
   char name[16 + 2*GFC_RANK_DIGITS + 1 + 1];
-  int idx = 2 * (dimen - 1) + restricted;
+  int idx = 2 * (codimen + dimen - 1) + restricted;
 
   gcc_assert (dimen >= 1 && codimen + dimen <= GFC_MAX_DIMENSIONS);
   if (gfc_array_descriptor_base[idx])
@@ -1551,8 +1551,7 @@ gfc_get_array_descriptor_base (int dimen
   /* Build the type node.  */
   fat_type = make_node (RECORD_TYPE);
 
-  sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT "_"
-	   GFC_RANK_PRINTF_FORMAT, dimen, codimen);
+  sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT, dimen + codimen);
   TYPE_NAME (fat_type) = get_identifier (name);
 
   /* Add the data member as the first element of the descriptor.  */
@@ -1629,8 +1628,7 @@ gfc_get_array_type_bounds (tree etype, i
     type_name = IDENTIFIER_POINTER (tmp);
   else
     type_name = "unknown";
-  sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_"
-	   GFC_RANK_PRINTF_FORMAT "_%.*s", dimen, codimen,
+  sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen + codimen,
 	   GFC_MAX_SYMBOL_LEN, type_name);
   TYPE_NAME (fat_type) = get_identifier (name);
 
Index: gcc/testsuite/gfortran.dg/coarray_13.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_13.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/coarray_13.f90	(revision 0)
@@ -0,0 +1,19 @@
+! { dg-do run }
+! { dg-options "-fcoarray=single" }
+!
+! Coarray support -- allocatable array coarrays
+! PR fortran/18918
+! PR fortran/43931
+!
+program test
+  implicit none
+  call one()
+contains
+  subroutine one()
+    integer, allocatable :: a(:)[:,:,:]
+    allocate(a(1)[-4:9,8,4:*])
+  end subroutine one
+  subroutine four(C)
+    integer, allocatable :: C(:)[:]
+ end subroutine four
+end program test

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]