This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran, committed] Some coarray fixes (PR 18918 and 48477)
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Wed, 06 Apr 2011 20:34:45 +0200
- Subject: [Patch, Fortran, committed] Some coarray fixes (PR 18918 and 48477)
I have committed the following three rather obvious patches (separately):
1. libgfortran/caf/mpi.c: I am now finally convinced that one indeed
need to make use of MPI_Initialized's return value when calling
MPI_Finalize. Thanks to all who pointed it out several times.
2. gcc/fortran/trans-intrinsic.c: Before the patch, the argument-free
version of this_image() was broken for -fcoarray=lib. This breakage
proves that one badly needs -fcoarray=lib test cases.
3. gcc/testsuite/gfortran.dg/coarray_13.f90: Reported as PR 48477. It
make sense to avoid accessing array element 140 of an array which only
has 3 elements ...
Committed as Revs. 172059, 172060 and 172061.
Tobias
Index: libgfortran/ChangeLog
===================================================================
--- libgfortran/ChangeLog (Revision 172058)
+++ libgfortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,10 @@
+2011-04-06 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ * caf/mpi.c (_gfortran_caf_init, _gfortran_caf_finalize):
+ Add global variable caf_mpi_initialized and use it for when
+ finalizing.
+
2011-04-04 Tobias Burnus <burnus@net-b.de>
* unix.c: Adapt stat DEFINEs since MinGW64 supports LFS.
Index: libgfortran/caf/mpi.c
===================================================================
--- libgfortran/caf/mpi.c (Revision 172058)
+++ libgfortran/caf/mpi.c (Arbeitskopie)
@@ -36,6 +36,7 @@ see the files COPYING3 and COPYING.RUNTIME respect
static void error_stop (int error) __attribute__ ((noreturn));
/* Global variables. */
+static int caf_mpi_initialized;
static int caf_this_image;
static int caf_num_images;
static MPI_Win caf_world_window;
@@ -50,12 +51,10 @@ static MPI_Win caf_world_window;
void
_gfortran_caf_init (int *argc, char ***argv, int *this_image, int *num_images)
{
- int flag;
-
- /* The following is only the case if one does not have a Fortran
- main program. */
- MPI_Initialized (&flag);
- if (!flag)
+ /* caf_mpi_initialized is only true if the main program is not written in
+ Fortran. */
+ MPI_Initialized (&caf_mpi_initialized);
+ if (!caf_mpi_initialized)
MPI_Init (argc, argv);
MPI_Comm_rank (MPI_COMM_WORLD, &caf_this_image);
@@ -69,15 +68,15 @@ _gfortran_caf_init (int *argc, char ***argv, int *
}
-/* Finalize coarray program. Note: This is only called before the
- program ends; thus the MPI_Initialized status of _gfortran_caf_init
- does not play a role. */
+/* Finalize coarray program. */
void
_gfortran_caf_finalize (void)
{
MPI_Win_free (&caf_world_window);
- MPI_Finalize ();
+
+ if (!caf_mpi_initialized)
+ MPI_Finalize ();
}
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 172058)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2011-04-06 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ * trans-intrinsic.c (gfc_conv_intrinsic_function): Fix
+ call for this_image.
+
2011-04-05 Nathan Froyd <froydnj@codesourcery.com>
* trans-intrinsic.c (gfc_build_intrinsic_lib_fndecls): Use
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (Revision 172058)
+++ gcc/fortran/trans-intrinsic.c (Arbeitskopie)
@@ -6260,7 +6260,7 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr
break;
case GFC_ISYM_THIS_IMAGE:
- if (expr->value.function.actual)
+ if (expr->value.function.actual->expr)
conv_intrinsic_cobound (se, expr);
else
trans_this_image (se, expr);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 172058)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2011-04-06 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ PR fortran/48477
+ * gfortran.dg/coarray_13.f90: Avoid out-of-bounds access.
+
2011-04-06 Steve Ellcey <sje@cup.hp.com>
* gcc.dg/mtune.c: Prune note from output.
@@ -33,7 +39,7 @@
2011-04-04 Yufeng Zhang <yufeng.zhang@arm.com>
- * g++.dg/abi/arm_cxa_vec1.C (__ARM_EABI__): Fix typo.
+ * g++.dg/abi/arm_cxa_vec1.C (__ARM_EABI__): Fix typo.
(cctor): Actually return the value.
(main): Cast return values.
Index: gcc/testsuite/gfortran.dg/coarray_13.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_13.f90 (Revision 172058)
+++ gcc/testsuite/gfortran.dg/coarray_13.f90 (Arbeitskopie)
@@ -105,10 +105,10 @@ contains
integer :: n
integer :: A(-1:3,0:4,-2:5,-4:7)[n+2:n+5,n-1:*]
- A(1,1,1,1) = 42
- if (A(1,1,1,1) /= 42) call abort()
- A(1,1,1,1)[4,n] = -42
- if (A(1,1,1,1)[4,n] /= -42) call abort()
+ A(-1,0,-2,-4) = 42
+ if (A(-1,0,-2,-4) /= 42) call abort()
+ A(1,0,-2,-4) = 99
+ if (A(1,0,-2,-4) /= 99) call abort()
if (this_image(A,dim=1) /= n+2) call abort()
if (lcobound (A,dim=1) /= n+2) call abort()