re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])

2010-04-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * array.c (gfc_match_array_spec): Add error for -fcoarray=none.
        * match.c (gfc_match_critical, sync_statement): Ditto.
        * gfortran.h (gfc_fcoarray): New enum.
        (gfc_option_t): Use it.
        * lang.opt (fcoarray): Add new flag.
        * invoke.texi (fcoarray): Document it.
        * options.c (gfc_init_options,gfc_handle_option): Handle
        * -fcoarray=.
        (gfc_handle_coarray_option): New function.

2010-04-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * gfortran.dg/coarray_2.f90: Add dg-options -fcoarray=single.
        * gfortran.dg/coarray_3.f90: Ditto.
        * gfortran.dg/coarray_4.f90: Ditto.
        * gfortran.dg/coarray_5.f90: Ditto.
        * gfortran.dg/coarray_6.f90: Ditto.
        * gfortran.dg/coarray_7.f90: Ditto.
        * gfortran.dg/coarray_8.f90: Ditto.
        * gfortran.dg/coarray_9.f90: New -fcoarray=none test.

From-SVN: r158016
This commit is contained in:
Tobias Burnus 2010-04-06 21:03:10 +02:00 committed by Tobias Burnus
parent 377949813a
commit f4d1d50a5a
13 changed files with 105 additions and 2 deletions

View File

@ -1,3 +1,15 @@
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* array.c (gfc_match_array_spec): Add error for -fcoarray=none.
* match.c (gfc_match_critical, sync_statement): Ditto.
* gfortran.h (gfc_fcoarray): New enum.
(gfc_option_t): Use it.
* lang.opt (fcoarray): Add new flag.
* invoke.texi (fcoarray): Document it.
* options.c (gfc_init_options,gfc_handle_option): Handle -fcoarray=.
(gfc_handle_coarray_option): New function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918

View File

@ -458,6 +458,12 @@ coarray:
== FAILURE)
goto cleanup;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
goto cleanup;
}
for (;;)
{
as->corank++;

View File

@ -563,6 +563,13 @@ typedef enum
}
init_local_integer;
typedef enum
{
GFC_FCOARRAY_NONE = 0,
GFC_FCOARRAY_SINGLE
}
gfc_fcoarray;
/************************* Structures *****************************/
/* Used for keeping things in balanced binary trees. */
@ -2158,6 +2165,7 @@ typedef struct
int fpe;
int rtcheck;
gfc_fcoarray coarray;
int warn_std;
int allow_std;

View File

@ -166,8 +166,8 @@ and warnings}.
@gccoptlist{-fno-automatic -ff2c -fno-underscoring @gol
-fwhole-file -fsecond-underscore @gol
-fbounds-check -fcheck-array-temporaries -fmax-array-constructor =@var{n} @gol
-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>}
-fmax-stack-var-size=@var{n} @gol
-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
-fcoarray=@var{<none|single>} -fmax-stack-var-size=@var{n} @gol
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
@ -1212,6 +1212,20 @@ is implemented as a reference to the link-time external symbol
for compatibility with @command{g77} and @command{f2c}, and is implied
by use of the @option{-ff2c} option.
@item -fcoarray=@var{<keyword>}
@opindex @code{fcoarray}
@cindex coarrays
@table @asis
@item @samp{none}
Disable coarray support; using coarray declarations and image-control
statements will produce a compile-time error. (Default)
@item @samp{single}
Single-image mode, i.e. @code{num_images()} is always one.
@end table
@item -fcheck=@var{<keyword>}
@opindex @code{fcheck}
@cindex array, bounds checking

View File

@ -348,6 +348,10 @@ frepack-arrays
Fortran
Copy array sections into a contiguous block on procedure entry
fcoarray=
Fortran RejectNegative JoinedOrMissing
-fcoarray=[...] Specify which coarray parallelization should be used
fcheck=
Fortran RejectNegative JoinedOrMissing
-fcheck=[...] Specify which runtime checks are to be performed

View File

@ -1743,6 +1743,12 @@ gfc_match_critical (void)
== FAILURE)
return MATCH_ERROR;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
return MATCH_ERROR;
}
if (gfc_find_state (COMP_CRITICAL) == SUCCESS)
{
gfc_error ("Nested CRITICAL block at %C");
@ -2138,6 +2144,12 @@ sync_statement (gfc_statement st)
== FAILURE)
return MATCH_ERROR;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
return MATCH_ERROR;
}
if (gfc_find_state (COMP_CRITICAL) == SUCCESS)
{
gfc_error ("Image control statement SYNC at %C in CRITICAL block");

View File

@ -130,6 +130,7 @@ gfc_init_options (unsigned int argc, const char **argv)
gfc_option.fpe = 0;
gfc_option.rtcheck = 0;
gfc_option.coarray = GFC_FCOARRAY_NONE;
/* Argument pointers cannot point to anything but their argument. */
flag_argument_noalias = 3;
@ -479,6 +480,18 @@ gfc_handle_fpe_trap_option (const char *arg)
}
static void
gfc_handle_coarray_option (const char *arg)
{
if (strcmp (arg, "none") == 0)
gfc_option.coarray = GFC_FCOARRAY_NONE;
else if (strcmp (arg, "single") == 0)
gfc_option.coarray = GFC_FCOARRAY_SINGLE;
else
gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg);
}
static void
gfc_handle_runtime_check_option (const char *arg)
{
@ -931,6 +944,9 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_handle_runtime_check_option (arg);
break;
case OPT_fcoarray_:
gfc_handle_coarray_option (arg);
break;
}
return result;

View File

@ -1,3 +1,13 @@
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* gfortran.dg/coarray_2.f90: Add dg-options -fcoarray=single.
* gfortran.dg/coarray_3.f90: Ditto.
* gfortran.dg/coarray_4.f90: Ditto.
* gfortran.dg/coarray_5.f90: Ditto.
* gfortran.dg/coarray_6.f90: Ditto.
* gfortran.dg/coarray_9.f90: New -fcoarray=none test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918

View File

@ -1,4 +1,5 @@
! { dg-do run }
! { dg-options "-fcoarray=single" }
! { dg-shouldfail "error stop" }
!
! Coarray support

View File

@ -1,4 +1,5 @@
! { dg-do compile }
! { dg-options "-fcoarray=single" }
!
! Coarray support
! PR fortran/18918

View File

@ -1,4 +1,5 @@
! { dg-do compile }
! { dg-options "-fcoarray=single" }
!
! Coarray support -- corank declarations
! PR fortran/18918

View File

@ -1,4 +1,5 @@
! { dg-do compile }
! { dg-options "-fcoarray=single" }
!
! Coarray support -- corank declarations
! PR fortran/18918

View File

@ -0,0 +1,17 @@
! { dg-do compile }
!
! PR fortran/18918
!
! Check for error if no -fcoarray= option has been given
!
integer :: a
integer :: b[*] ! { dg-error "Coarrays disabled" }
error stop "Error"
sync all ! { dg-error "Coarrays disabled" }
critical ! { dg-error "Coarrays disabled" }
end critical ! { dg-error "Expecting END PROGRAM statement" }
end