From: Steven G. Kargl Date: Sat, 17 Aug 2019 18:16:51 +0000 (+0000) Subject: re PR fortran/91471 (f951: internal compiler error: gfc_variable_attr(): Bad array... X-Git-Tag: releases/gcc-9.3.0~710 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7840406b9bbe41d9e2fec7f4fc4ffdd26de4497;p=thirdparty%2Fgcc.git re PR fortran/91471 (f951: internal compiler error: gfc_variable_attr(): Bad array reference) 2019-08-17 Steven G. Kargl 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-17 Steven G. Kargl PR fortran/91471 * gfortran.dg/pr91471.f90: New test. From-SVN: r274612 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9904d79dd68a..87eda46365b7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-08-17 Steven G. Kargl + + 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-17 Steven G. Kargl PR fortran/78739 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index e918372ef850..4af1db5f4bda 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2559,12 +2559,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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c62c6a259d4..4c944f8aa478 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-17 Steven G. Kargl + + PR fortran/91471 + * gfortran.dg/pr91471.f90: New test. + 2019-08-17 Steven G. Kargl PR fortran/78739 diff --git a/gcc/testsuite/gfortran.dg/pr91471.f90 b/gcc/testsuite/gfortran.dg/pr91471.f90 new file mode 100644 index 000000000000..fa798444c1df --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91471.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/91471 +! Code contributed by Sameeran Joshi +! +! 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