aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/intrinsic.cc
diff options
context:
space:
mode:
authorHaochen Gui <guihaoc@gcc.gnu.org>2023-03-24 10:45:52 +0800
committerHaochen Gui <guihaoc@gcc.gnu.org>2023-03-24 10:47:13 +0800
commit3b67db31236631432e7f6d74ed49af9ae2183a4d (patch)
tree8bce8ec5e48fcd55fa984121d1b690206356e297 /gcc/fortran/intrinsic.cc
parent08ef17c75777ef9e4e7ead132ccd7a6d03ae6020 (diff)
downloadgcc-3b67db31236631432e7f6d74ed49af9ae2183a4d.zip
gcc-3b67db31236631432e7f6d74ed49af9ae2183a4d.tar.gz
gcc-3b67db31236631432e7f6d74ed49af9ae2183a4d.tar.bz2
Fortran: Escalate failure when Hollerith constant to real conversion fails
gcc/fortran/ PR target/103628 * target-memory.cc (gfc_interpret_float): Return FAIL when native_interpret_expr gets a NULL tree. * arith.cc (gfc_hollerith2real): Return NULL when gfc_interpret_float fails. * error.cc (gfc_buffered_p): Define. * gfortran.h (gfc_buffered_p): Declare. * intrinsic.cc: Add diagnostic.h to include list. (do_simplify): Save errorcount and check it at finish. Report a "Cannot simplify expression" error on a bad result if error count doesn't change and no other errors buffered. gcc/testsuite/ PR target/103628 * gfortran.dg/assumed_size_refs_2.f90: Check "Cannot simplify expression" error. * gfortran.dg/unpack_field_1.f90: Likewise. * gfortran.dg/pr103628.f90: New. Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
Diffstat (limited to 'gcc/fortran/intrinsic.cc')
-rw-r--r--gcc/fortran/intrinsic.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index 64821c8..1a26b7a 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "options.h"
#include "gfortran.h"
#include "intrinsic.h"
+#include "diagnostic.h" /* For errorcount. */
/* Namespace to hold the resolved symbols for intrinsic subroutines. */
static gfc_namespace *gfc_intrinsic_namespace;
@@ -4620,6 +4621,7 @@ do_simplify (gfc_intrinsic_sym *specific, gfc_expr *e)
{
gfc_expr *result, *a1, *a2, *a3, *a4, *a5, *a6;
gfc_actual_arglist *arg;
+ int old_errorcount = errorcount;
/* Max and min require special handling due to the variable number
of args. */
@@ -4708,7 +4710,12 @@ do_simplify (gfc_intrinsic_sym *specific, gfc_expr *e)
finish:
if (result == &gfc_bad_expr)
- return false;
+ {
+ if (errorcount == old_errorcount
+ && (!gfc_buffered_p () || !gfc_error_flag_test ()))
+ gfc_error ("Cannot simplify expression at %L", &e->where);
+ return false;
+ }
if (result == NULL)
resolve_intrinsic (specific, e); /* Must call at run-time */