aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-06-29 15:15:49 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:15:24 -0300
commitf35b15a0758c8d71314bf9828ae9351efc5f8107 (patch)
tree47e7b985306ccaa22fea5c9cb29d10b8843bfc8b
parent41f7d2f5cb60aa4d61373dcaec22ff2895a11dba (diff)
downloadgcc-f35b15a0758c8d71314bf9828ae9351efc5f8107.zip
gcc-f35b15a0758c8d71314bf9828ae9351efc5f8107.tar.gz
gcc-f35b15a0758c8d71314bf9828ae9351efc5f8107.tar.bz2
PR fortran/71706 - ICE on using sync images with -fcheck=bounds
The run-time checking code did not properly convert the kind of the argument to SYNC IMAGES, leading to an error in verify_gimple. Fix that. gcc/fortran/ PR fortran/71706 * trans-stmt.c (gfc_trans_sync): Do proper kind conversion in bounds-checking code.
-rw-r--r--gcc/fortran/trans-stmt.c6
-rw-r--r--gcc/testsuite/gfortran.dg/pr71706.f9010
2 files changed, 13 insertions, 3 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 4e9b5ad..54b56c4 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -1228,6 +1228,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
if (code->expr1 && (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
&& code->expr1->rank == 0)
{
+ tree images2 = fold_convert (integer_type_node, images);
tree cond;
if (flag_coarray != GFC_FCOARRAY_LIB)
cond = fold_build2_loc (input_location, NE_EXPR, logical_type_node,
@@ -1239,7 +1240,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
2, integer_zero_node,
build_int_cst (integer_type_node, -1));
cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
- images, tmp);
+ images2, tmp);
cond2 = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
images,
build_int_cst (TREE_TYPE (images), 1));
@@ -1248,8 +1249,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
}
gfc_trans_runtime_check (true, false, cond, &se.pre,
&code->expr1->where, "Invalid image number "
- "%d in SYNC IMAGES",
- fold_convert (integer_type_node, images));
+ "%d in SYNC IMAGES", images2);
}
/* Per F2008, 8.5.1, a SYNC MEMORY is implied by calling the
diff --git a/gcc/testsuite/gfortran.dg/pr71706.f90 b/gcc/testsuite/gfortran.dg/pr71706.f90
new file mode 100644
index 0000000..860c1c8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr71706.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib -fcheck=all -fdefault-integer-8" }
+! PR fortran/71706 - ICE on using sync images with -fcheck=bounds
+
+program p
+ integer, volatile :: me = 1
+ sync images (me)
+ sync images (int (me, 2))
+ sync images (int (me, 8))
+end