Commit bf1b77dd by Paul Thomas

re PR fortran/56852 (ICE on invalid: "Bad array reference" for an undeclared loop variable)

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

From-SVN: r221955
parent 86c5a5c3
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.
2015-04-07 Andre Vehreschild <vehre@gmx.de>
PR fortran/65548
......
......@@ -2138,7 +2138,7 @@ check_substring:
symbol_attribute
gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
{
int dimension, codimension, pointer, allocatable, target;
int dimension, codimension, pointer, allocatable, target, n;
symbol_attribute attr;
gfc_ref *ref;
gfc_symbol *sym;
......@@ -2195,6 +2195,24 @@ 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. */
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");
}
......
2013-04-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/56852
* gfortran.dg/pr56852.f90 : New test
2015-04-09 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
......
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment