re PR fortran/84734 (Compiling codes with insane array dimensions gives an ICE after...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 10 Mar 2018 18:34:12 +0000 (18:34 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 10 Mar 2018 18:34:12 +0000 (18:34 +0000)
2018-03-09  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/84734
* arith.c (check_result, eval_intrinsic):  If result overflows, pass
the expression up the chain instead of a NULL pointer.

2018-03-09  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/84734
* gfortran.dg/pr84734.f90: New test.

From-SVN: r258416

gcc/fortran/ChangeLog
gcc/fortran/arith.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr84734.f90 [new file with mode: 0644]

index 796b58dd6f31c8da235705ac72a3753e248364a3..d4042189ab3ec20c9274b3a2c6c9796428d0b84e 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/84734
+       * arith.c (check_result, eval_intrinsic):  If result overflows, pass
+       the expression up the chain instead of a NULL pointer.
+
 2018-03-07  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/64124
index 8f328fe4c52c1e3661b44baf177aa63bd4aabac1..6f97d0f978451f2243478ae04788f2d4f9acbdcd 100644 (file)
@@ -555,10 +555,10 @@ check_result (arith rc, gfc_expr *x, gfc_expr *r, gfc_expr **rp)
       val = ARITH_OK;
     }
 
-  if (val != ARITH_OK)
-    gfc_free_expr (r);
-  else
+  if (val == ARITH_OK || val == ARITH_OVERFLOW)
     *rp = r;
+  else
+    gfc_free_expr (r);
 
   return val;
 }
@@ -1603,9 +1603,13 @@ eval_intrinsic (gfc_intrinsic_op op,
   if (rc != ARITH_OK)
     {
       gfc_error (gfc_arith_error (rc), &op1->where);
+      if (rc == ARITH_OVERFLOW)
+       goto done;
       return NULL;
     }
 
+done:
+
   gfc_free_expr (op1);
   gfc_free_expr (op2);
   return result;
index bf028b86a22a345fee06bd330fd0f0ae15d6b41f..323e8360781e7ee2dc0c93bc37e63410e9a9a008 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/84734
+       * gfortran.dg/pr84734.f90: New test.
+
 2018-03-10  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/prot3.adb: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr84734.f90 b/gcc/testsuite/gfortran.dg/pr84734.f90
new file mode 100644 (file)
index 0000000..4b117ae
--- /dev/null
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/84734
+   integer :: b(huge(1_8)+1_8) = 0 ! { dg-error "Arithmetic overflow" }
+   end