ICE on wrong code [PR94192].
authorLinus Koenig <link@sig-st.de>
Mon, 13 Apr 2020 14:30:44 +0000 (16:30 +0200)
committerThomas König <tkoenig@gcc.gnu.org>
Mon, 13 Apr 2020 14:32:38 +0000 (16:32 +0200)
The idea is not have another resolution of a pointer if an error has
occurred previously.

2020-04-13  Linus Koenig <link@sig-st.de>

PR fortran/94192
* resolve.c (resolve_fl_var_and_proc): Set flag "error" to 1 if
pointer is found to not have an assumed rank or a deferred shape.
* simplify.c (simplify_bound): If an error has been issued for a
given pointer, one should not attempt to find its bounds.

2020-04-13  Linus Koenig <link@sig-st.de>

PR fortran/94192
* gfortran.dg/bound_resolve_after_error_1.f90: New test.

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/bound_resolve_after_error_1.f90 [new file with mode: 0644]

index e2ebb96d7992509969742db7e73e79827e4dc708..96835dea4bf4f95ab024b2673742d40474fbc066 100644 (file)
@@ -1,3 +1,11 @@
+2020-04-13  Linus Koenig <link@sig-st.de>
+
+       PR fortran/94192
+       * resolve.c (resolve_fl_var_and_proc): Set flag "error" to 1 if
+       pointer is found to not have an assumed rank or a deferred shape.
+       * simplify.c (simplify_bound): If an error has been issued for a
+       given pointer, one should not attempt to find its bounds.
+
 2020-04-09  Fritz Reese  <foreese@gcc.gnu.org>
 
        PR fortran/87923
index ccd2a5e3b7d0fe16984d7fc3a0a66ca44c3fefb2..9b95200c241aa35f79067028d56a0c211398a652 100644 (file)
@@ -12622,6 +12622,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag)
        {
          gfc_error ("Array pointer %qs at %L must have a deferred shape or "
                     "assumed rank", sym->name, &sym->declared_at);
+         sym->error = 1;
          return false;
        }
     }
index f63f63c9ef659f79b95100b6636a77cb4918c652..807565b4e80d932f3697771a26f1f077c9ace0c9 100644 (file)
@@ -4159,6 +4159,10 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
   gfc_array_spec *as;
   int d;
 
+  /* Do not attempt to resolve if error has already been issued.  */
+  if (array->symtree && array->symtree->n.sym->error)
+    return NULL;
+
   if (array->ts.type == BT_CLASS)
     return NULL;
 
index 9f64453130683b7a2dfc3eb0760d97bf69bb54aa..3c3352f5c8be39449cd2df5edbc5536b18714e04 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-13  Linus Koenig <link@sig-st.de>
+
+       PR fortran/94192
+       * gfortran.dg/bound_resolve_after_error_1.f90: New test.
+
 2020-04-13  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/94426
diff --git a/gcc/testsuite/gfortran.dg/bound_resolve_after_error_1.f90 b/gcc/testsuite/gfortran.dg/bound_resolve_after_error_1.f90
new file mode 100644 (file)
index 0000000..35cc240
--- /dev/null
@@ -0,0 +1,13 @@
+! Testcase for bound check after issued error
+! See PR 94192
+! { dg-do compile }
+program bound_for_illegal
+  
+contains
+
+  subroutine bnds(a)  ! { dg-error "must have a deferred shape or assumed rank" }
+    integer, pointer, intent(in) :: a(1:2)
+    print *,lbound(a)
+  end subroutine bnds
+
+end program bound_for_illegal