fortran/array.c | 6 ++++++ fortran/gfortran.h | 8 ++++++++ fortran/invoke.texi | 18 ++++++++++++++++-- fortran/lang.opt | 4 ++++ fortran/match.c | 12 ++++++++++++ fortran/options.c | 16 ++++++++++++++++ testsuite/gfortran.dg/coarray_2.f90 | 1 + testsuite/gfortran.dg/coarray_3.f90 | 1 + testsuite/gfortran.dg/coarray_4.f90 | 1 + testsuite/gfortran.dg/coarray_6.f90 | 1 + testsuite/gfortran.dg/coarray_7.f90 | 2 +- testsuite/gfortran.dg/coarray_8.f90 | 2 +- testsuite/gfortran.dg/coarray_9.f90 | 17 +++++++++++++++++ 13 files changed, 85 insertions(+), 4 deletions(-) 2010-03-31 Tobias Burnus 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-03-31 Tobias Burnus 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. diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index bc3148c..d9ca043 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -527,6 +527,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++; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 2dd3715..8fb0090 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -562,6 +562,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. */ @@ -2159,6 +2166,7 @@ typedef struct int fpe; int rtcheck; + gfc_fcoarray coarray; int warn_std; int allow_std; diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index efcf5ef..963ff49 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -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{} --fmax-stack-var-size=@var{n} @gol +-fcheck=@var{} @gol +-fcoarray=@var{} -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{} @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{} +@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{} @opindex @code{fcheck} @cindex array, bounds checking diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 7ea06c2..8cf20d8 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -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 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 0d8518b..3341ef6 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1750,6 +1750,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"); @@ -2145,6 +2151,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"); diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index bcde573..05da214 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -129,6 +129,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) { int result, pos = 0, n; @@ -930,6 +943,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; diff --git a/gcc/testsuite/gfortran.dg/coarray_2.f90 b/gcc/testsuite/gfortran.dg/coarray_2.f90 index 1fcb9b8..902a0dd 100644 --- a/gcc/testsuite/gfortran.dg/coarray_2.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_2.f90 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-fcoarray=single" } ! { dg-shouldfail "error stop" } ! ! Coarray support diff --git a/gcc/testsuite/gfortran.dg/coarray_3.f90 b/gcc/testsuite/gfortran.dg/coarray_3.f90 index 648f2fa..63c3bd3 100644 --- a/gcc/testsuite/gfortran.dg/coarray_3.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_3.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-fcoarray=single" } ! ! Coarray support ! PR fortran/18918 diff --git a/gcc/testsuite/gfortran.dg/coarray_4.f90 b/gcc/testsuite/gfortran.dg/coarray_4.f90 index cb693ea..5607ec9 100644 --- a/gcc/testsuite/gfortran.dg/coarray_4.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_4.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-fcoarray=single" } ! ! Coarray support -- corank declarations ! PR fortran/18918 diff --git a/gcc/testsuite/gfortran.dg/coarray_6.f90 b/gcc/testsuite/gfortran.dg/coarray_6.f90 index b6d8b49..d3c600b 100644 --- a/gcc/testsuite/gfortran.dg/coarray_6.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_6.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-fcoarray=single" } ! ! Coarray support -- corank declarations ! PR fortran/18918 diff --git a/gcc/testsuite/gfortran.dg/coarray_7.f90 b/gcc/testsuite/gfortran.dg/coarray_7.f90 index a32bf88..bb23c78 100644 --- a/gcc/testsuite/gfortran.dg/coarray_7.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_7.f90 @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-fmax-errors=1000" } +! { dg-options "-fcoarray=single -fmax-errors=1000" } ! ! PR fortran/18918 ! diff --git a/gcc/testsuite/gfortran.dg/coarray_8.f90 b/gcc/testsuite/gfortran.dg/coarray_8.f90 index 0ab1190..6a385f8 100644 --- a/gcc/testsuite/gfortran.dg/coarray_8.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_8.f90 @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-fmax-errors=1000" } +! { dg-options "-fcoarray=single -fmax-errors=1000" } ! ! PR fortran/18918 ! diff --git a/gcc/testsuite/gfortran.dg/coarray_9.f90 b/gcc/testsuite/gfortran.dg/coarray_9.f90 new file mode 100644 index 0000000..d44cdda --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_9.f90 @@ -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