aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2017-03-05 12:35:47 +0100
committerAndre Vehreschild <vehre@gcc.gnu.org>2017-03-05 12:35:47 +0100
commitef78bc3c0b9d23b3decd8b6439c99a025ebc8f28 (patch)
tree992e5a7217ac50b58fd957616898363d731e3380 /gcc/fortran/simplify.c
parent55a8bcbb1fc83958e12037974b20f2164840ca42 (diff)
downloadgcc-ef78bc3c0b9d23b3decd8b6439c99a025ebc8f28.zip
gcc-ef78bc3c0b9d23b3decd8b6439c99a025ebc8f28.tar.gz
gcc-ef78bc3c0b9d23b3decd8b6439c99a025ebc8f28.tar.bz2
check.c (positive_check): Add new function checking constant for being greater then zero.
gcc/fortran/ChangeLog: 2017-03-05 Andre Vehreschild <vehre@gcc.gnu.org> Alessandro Fanfarillo <fanfarillo.gcc@gmail.com> * check.c (positive_check): Add new function checking constant for being greater then zero. (gfc_check_image_status): Add checking of image_status arguments. (gfc_check_failed_or_stopped_images): Same but for failed_- and stopped_images function. * dump-parse-tree.c (show_code_node): Added output of FAIL IMAGE. * gfortran.h (enum gfc_statement): Added FAIL_IMAGE_ST. (enum gfc_isym_id): Added new intrinsic symbols. (enum gfc_exec_op): Added EXEC_FAIL_IMAGE. * gfortran.texi: Added description for the new API functions. Updated coverage of gfortran of TS18508. * intrinsic.c (add_functions): Added symbols to resolve new intrinsic functions. * intrinsic.h: Added prototypes. * iresolve.c (gfc_resolve_failed_images): Resolve the failed_images intrinsic. (gfc_resolve_image_status): Same for image_status. (gfc_resolve_stopped_images): Same for stopped_images. * libgfortran.h: Added prototypes. * match.c (gfc_match_if): Added matching of FAIL IMAGE statement. (gfc_match_fail_image): Match a FAIL IMAGE statement. * match.h: Added prototype. * parse.c (decode_statement): Added matching for FAIL IMAGE. (next_statement): Same. (gfc_ascii_statement): Same. * resolve.c: Same. * simplify.c (gfc_simplify_failed_or_stopped_images): For COARRAY= single a constant result can be returne.d (gfc_simplify_image_status): For COARRAY=single the result is constant. * st.c (gfc_free_statement): Added FAIL_IMAGE handling. * trans-decl.c (gfc_build_builtin_function_decls): Added decls of the new intrinsics. * trans-expr.c (gfc_conv_procedure_call): This is first time all arguments of a function are optional, which is now handled here correctly. * trans-intrinsic.c (conv_intrinsic_image_status): Translate image_status. (gfc_conv_intrinsic_function): Add support for image_status. (gfc_is_intrinsic_libcall): Add support for the remaining new intrinsics. * trans-stmt.c (gfc_trans_fail_image): Trans a fail image. * trans-stmt.h: Add the prototype for the above. * trans.c (trans_code): Dispatch for fail_image. * trans.h: Add the trees for the new intrinsics. libgfortran/ChangeLog: 2017-03-05 Andre Vehreschild <vehre@gcc.gnu.org> Alessandro Fanfarillo <fanfarillo.gcc@gmail.com> * caf/libcaf.h: Added prototypes and stat codes for failed and stopped images. * caf/single.c (void _gfortran_caf_fail_image): Add the routine. (int _gfortran_caf_image_status): Same. (_gfortran_caf_failed_images): Same. (_gfortran_caf_stopped_images): Same. gcc/testsuite/ChangeLog: 2017-03-05 Andre Vehreschild <vehre@gcc.gnu.org> Alessandro Fanfarillo <fanfarillo.gcc@gmail.com> * gfortran.dg/coarray/fail_image_1.f08: New test. * gfortran.dg/coarray/fail_image_2.f08: New test. * gfortran.dg/coarray/failed_images_1.f08: New test. * gfortran.dg/coarray/failed_images_2.f08: New test. * gfortran.dg/coarray/image_status_1.f08: New test. * gfortran.dg/coarray/image_status_2.f08: New test. * gfortran.dg/coarray/stopped_images_1.f08: New test. * gfortran.dg/coarray/stopped_images_2.f08: New test. * gfortran.dg/coarray_fail_st.f90: New test. * gfortran.dg/coarray_failed_images_1.f08: New test. * gfortran.dg/coarray_image_status_1.f08: New test. * gfortran.dg/coarray_stopped_images_1.f08: New test. From-SVN: r245900
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 8ffe75a..169aef1 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -2466,6 +2466,37 @@ gfc_simplify_exponent (gfc_expr *x)
gfc_expr *
+gfc_simplify_failed_or_stopped_images (gfc_expr *team ATTRIBUTE_UNUSED,
+ gfc_expr *kind)
+{
+ if (flag_coarray == GFC_FCOARRAY_NONE)
+ {
+ gfc_current_locus = *gfc_current_intrinsic_where;
+ gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
+ return &gfc_bad_expr;
+ }
+
+ if (flag_coarray == GFC_FCOARRAY_SINGLE)
+ {
+ gfc_expr *result;
+ int actual_kind;
+ if (kind)
+ gfc_extract_int (kind, &actual_kind);
+ else
+ actual_kind = gfc_default_integer_kind;
+
+ result = gfc_get_array_expr (BT_INTEGER, actual_kind, &gfc_current_locus);
+ result->rank = 1;
+ return result;
+ }
+
+ /* For fcoarray = lib no simplification is possible, because it is not known
+ what images failed or are stopped at compile time. */
+ return NULL;
+}
+
+
+gfc_expr *
gfc_simplify_float (gfc_expr *a)
{
gfc_expr *result;
@@ -6763,6 +6794,36 @@ gfc_simplify_image_index (gfc_expr *coarray, gfc_expr *sub)
return result;
}
+gfc_expr *
+gfc_simplify_image_status (gfc_expr *image, gfc_expr *team ATTRIBUTE_UNUSED)
+{
+ if (flag_coarray == GFC_FCOARRAY_NONE)
+ {
+ gfc_current_locus = *gfc_current_intrinsic_where;
+ gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
+ return &gfc_bad_expr;
+ }
+
+ /* Simplification is possible for fcoarray = single only. For all other modes
+ the result depends on runtime conditions. */
+ if (flag_coarray != GFC_FCOARRAY_SINGLE)
+ return NULL;
+
+ if (gfc_is_constant_expr (image))
+ {
+ gfc_expr *result;
+ result = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind,
+ &image->where);
+ if (mpz_get_si (image->value.integer) == 1)
+ mpz_set_si (result->value.integer, 0);
+ else
+ mpz_set_si (result->value.integer, GFC_STAT_STOPPED_IMAGE);
+ return result;
+ }
+ else
+ return NULL;
+}
+
gfc_expr *
gfc_simplify_this_image (gfc_expr *coarray, gfc_expr *dim,