diff mbox series

PR fortran/91471 -- Remove a gfc_internal_error()

Message ID 20190816235330.GA51877@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/91471 -- Remove a gfc_internal_error() | expand

Commit Message

Steve Kargl Aug. 16, 2019, 11:53 p.m. UTC
The attach patch has been tested on x86_64-*-freebsd.
The code, testcase, and ChangeLog should provide 
sufficient information.  OK to commit?

2019-08-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91471
	* primary.c (gfc_variable_attr): Remove a gfc_internal_error(),
	which cannot be reached by conforming Fortran code, but seems to
	be reachable from nonconforming Fortran code.  Treat the AR_UNKNOWN
	case as a no-op.

2019-08-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91471
	* gfortran.dg/pr91471.f90: New test.

Comments

Janne Blomqvist Aug. 17, 2019, 5:49 a.m. UTC | #1
On Sat, Aug 17, 2019 at 2:53 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> The attach patch has been tested on x86_64-*-freebsd.
> The code, testcase, and ChangeLog should provide
> sufficient information.  OK to commit?
>
> 2019-08-16  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/91471
>         * primary.c (gfc_variable_attr): Remove a gfc_internal_error(),
>         which cannot be reached by conforming Fortran code, but seems to
>         be reachable from nonconforming Fortran code.  Treat the AR_UNKNOWN
>         case as a no-op.
>
> 2019-08-16  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/91471
>         * gfortran.dg/pr91471.f90: New test.

Ok.
diff mbox series

Patch

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 274578)
+++ gcc/fortran/primary.c	(working copy)
@@ -2597,12 +2597,10 @@  gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
 	    break;
 
 	  case AR_UNKNOWN:
-	    /* If any of start, end or stride is not integer, there will
-	       already have been an error issued.  */
-	    int errors;
-	    gfc_get_errors (NULL, &errors);
-	    if (errors == 0)
-	      gfc_internal_error ("gfc_variable_attr(): Bad array reference");
+	    /* For standard conforming code, AR_UNKNOWN should not happen.
+	       For nonconforming code, gfortran can end up here.  Treat it 
+	       as a no-op.  */
+	    break;
 	  }
 
 	break;
Index: gcc/testsuite/gfortran.dg/pr91471.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91471.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91471.f90	(working copy)
@@ -0,0 +1,14 @@ 
+! { dg-do compile }
+! PR fortran/91471
+! Code contributed by Sameeran Joshi <SameeranJayant dot Joshi at amd dot com>
+!
+! This invalid code (x(1) is referenced, but never set) caused an ICE due
+! to hitting a gfc_internal_error() in primary.c (gfc_variable_attr).  The
+! fix is to remove that gfc_internal_error().
+! 
+program dynamic
+   implicit none
+   integer, dimension(:), allocatable :: x
+   allocate(x(1))
+   stop x(1)
+end program dynamic