aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2018-06-08 22:04:11 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2018-06-08 22:04:11 +0000
commitd1ecece9af3adc46eb1cc716608c38692d57f9c1 (patch)
treee24f8e9128ee4c3b371e623ecdbdba86ba21bc63 /gcc/fortran
parent058872eaadac43dcf75839ba6b951619fea14fe1 (diff)
downloadgcc-d1ecece9af3adc46eb1cc716608c38692d57f9c1.zip
gcc-d1ecece9af3adc46eb1cc716608c38692d57f9c1.tar.gz
gcc-d1ecece9af3adc46eb1cc716608c38692d57f9c1.tar.bz2
re PR fortran/85631 (Runtime error message array bound mismatch with nonzero optimization)
2018-06-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/85631 * trans.h (gfc_ss): Add field no_bounds_check. * trans-array.c (gfc_conv_ss_startstride): If flag_realloc_lhs and ss->no_bounds_check is set, do not use runtime checks. * trans-expr.c (gfc_trans_assignment_1): Set lss->no_bounds_check for reallocatable lhs. 2018-06-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/85631 * gfortran.dg/bounds_check_20.f90: New test. From-SVN: r261348
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/trans-array.c4
-rw-r--r--gcc/fortran/trans-expr.c15
-rw-r--r--gcc/fortran/trans.h1
4 files changed, 22 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index dffc7f4..dbda6ef 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,6 +1,15 @@
+2018-06-08 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/85631
+ * trans.h (gfc_ss): Add field no_bounds_check.
+ * trans-array.c (gfc_conv_ss_startstride): If flag_realloc_lhs and
+ ss->no_bounds_check is set, do not use runtime checks.
+ * trans-expr.c (gfc_trans_assignment_1): Set lss->no_bounds_check
+ for reallocatable lhs.
+
2018-06-08 Steven G. Kargl <kargl@gcc.gnu.org>
- PR fortran/86059
+ PR fortran/86059
* array.c (match_array_cons_element): NULL() cannot be in an
array constructor.
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 7e6cea1..97c4725 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -4304,7 +4304,7 @@ done:
}
}
- /* The rest is just runtime bound checking. */
+ /* The rest is just runtime bounds checking. */
if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
{
stmtblock_t block;
@@ -4334,7 +4334,7 @@ done:
continue;
/* Catch allocatable lhs in f2003. */
- if (flag_realloc_lhs && ss->is_alloc_lhs)
+ if (flag_realloc_lhs && ss->no_bounds_check)
continue;
expr = ss_info->expr;
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 8bf5504..f855951 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -9982,12 +9982,15 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
/* Walk the lhs. */
lss = gfc_walk_expr (expr1);
- if (gfc_is_reallocatable_lhs (expr1)
- && !(expr2->expr_type == EXPR_FUNCTION
- && expr2->value.function.isym != NULL
- && !(expr2->value.function.isym->elemental
- || expr2->value.function.isym->conversion)))
- lss->is_alloc_lhs = 1;
+ if (gfc_is_reallocatable_lhs (expr1))
+ {
+ lss->no_bounds_check = 1;
+ if (!(expr2->expr_type == EXPR_FUNCTION
+ && expr2->value.function.isym != NULL
+ && !(expr2->value.function.isym->elemental
+ || expr2->value.function.isym->conversion)))
+ lss->is_alloc_lhs = 1;
+ }
rss = NULL;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 049fcd6..1813882 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -330,6 +330,7 @@ typedef struct gfc_ss
struct gfc_loopinfo *loop;
unsigned is_alloc_lhs:1;
+ unsigned no_bounds_check:1;
}
gfc_ss;
#define gfc_get_ss() XCNEW (gfc_ss)