From 8405874a0e2db1806332ead2dcf3e9ec563075aa Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Thu, 19 Dec 2019 15:13:25 +0000 Subject: Prevent conversion of character data in array constructors. Fix for PR fortran/92896 [10 Regression] [DEC] ICE in reduce_unary, at fortran/arith.c:1283. This was caused by an unintended side affect of "Allow CHARACTER literals in assignments and data statements" (revision 277975). If the conversion occurs in a array constructor it is rejected. From-SVN: r279583 --- gcc/fortran/intrinsic.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gcc/fortran/intrinsic.c') diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 76b53bb..c913f5a 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -5096,10 +5096,15 @@ gfc_convert_type (gfc_expr *expr, gfc_typespec *ts, int eflag) 1 Generate a gfc_error() 2 Generate a gfc_internal_error(). - 'wflag' controls the warning related to conversion. */ + 'wflag' controls the warning related to conversion. + + 'array' indicates whether the conversion is in an array constructor. + Non-standard conversion from character to numeric not allowed if true. +*/ bool -gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag) +gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag, + bool array) { gfc_intrinsic_sym *sym; gfc_typespec from_ts; @@ -5142,6 +5147,12 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag) && gfc_compare_types (&expr->ts, ts)) return true; + /* If array is true then conversion is in an array constructor where + non-standard conversion is not allowed. */ + if (array && from_ts.type == BT_CHARACTER + && (gfc_numeric_ts (ts) || ts->type == BT_LOGICAL)) + goto bad; + sym = find_conv (&expr->ts, ts); if (sym == NULL) goto bad; -- cgit v1.1