public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR56852 - [4.8/4.9/5 Regression] ICE on invalid: "Bad array reference" for an undeclared loop variable
@ 2015-04-09  7:40 Paul Richard Thomas
  0 siblings, 0 replies; only message in thread
From: Paul Richard Thomas @ 2015-04-09  7:40 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

Dear All,

I intend to commit this patch tonight, unless there are objections. It
is safe, since it skips an ICE if the conditions in the ChangeLog are
met.

Bootstraps and regtests on x86_64/FC21.

Paul

2013-04-09  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/56852
    * primary.c (gfc_variable_attr): Avoid ICE on AR_UNKNOWN if any
    of the index variables are untyped and errors are present.

2013-04-09  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/56852
    * gfortran.dg/pr56852.f90 : New test

[-- Attachment #2: commit.diff --]
[-- Type: text/plain, Size: 2183 bytes --]

Index: gcc/fortran/primary.c
===================================================================
*** gcc/fortran/primary.c	(revision 221941)
--- gcc/fortran/primary.c	(working copy)
*************** check_substring:
*** 2138,2144 ****
  symbol_attribute
  gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
  {
!   int dimension, codimension, pointer, allocatable, target;
    symbol_attribute attr;
    gfc_ref *ref;
    gfc_symbol *sym;
--- 2138,2144 ----
  symbol_attribute
  gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
  {
!   int dimension, codimension, pointer, allocatable, target, n;
    symbol_attribute attr;
    gfc_ref *ref;
    gfc_symbol *sym;
*************** gfc_variable_attr (gfc_expr *expr, gfc_t
*** 2195,2201 ****
  	    break;

  	  case AR_UNKNOWN:
! 	    gfc_internal_error ("gfc_variable_attr(): Bad array reference");
  	  }

  	break;
--- 2195,2219 ----
  	    break;

  	  case AR_UNKNOWN:
! 	    /* If any of start, end or stride is not integer, there will
! 	       already have been an error issued.  */
! 	    for (n = 0; n < ref->u.ar.as->rank; n++)
! 	      {
! 		int errors;
! 		gfc_get_errors (NULL, &errors);
! 		if (((ref->u.ar.start[n]
! 		      && ref->u.ar.start[n]->ts.type == BT_UNKNOWN)
! 		     ||
! 		     (ref->u.ar.end[n]
! 		      && ref->u.ar.end[n]->ts.type == BT_UNKNOWN)
! 		     ||
! 		     (ref->u.ar.stride[n]
! 		      && ref->u.ar.stride[n]->ts.type == BT_UNKNOWN))
! 		    && errors > 0)
! 		  break;
! 	      }
! 	    if (n == ref->u.ar.as->rank)
! 	      gfc_internal_error ("gfc_variable_attr(): Bad array reference");
  	  }

  	break;
Index: gcc/testsuite/gfortran.dg/pr56852.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr56852.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/pr56852.f90	(working copy)
***************
*** 0 ****
--- 1,11 ----
+ ! { dg-do compile }
+ ! Test the fix for pr56852, where an ICE would occur after the error.
+ !
+ ! Contributed by Lorenz Huedepohl  <bugs@stellardeath.org>
+ !
+ program test
+   implicit none
+   real :: a(4)
+   ! integer :: i
+   read(0) (a(i),i=1,4) ! { dg-error "has no IMPLICIT type" }
+ end program

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-09  7:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09  7:40 [Patch, fortran] PR56852 - [4.8/4.9/5 Regression] ICE on invalid: "Bad array reference" for an undeclared loop variable Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).