From: Steven G. Kargl Date: Sat, 17 Aug 2019 14:23:10 +0000 (+0000) Subject: re PR fortran/91471 (f951: internal compiler error: gfc_variable_attr(): Bad array... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f81c2a3c54d8ea9ebd7c703eef9f6d09088eb29;p=gcc.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: r274603 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a3b9e6bf486..130c3df2e46 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 Janne Blomqvist PR fortran/68401 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 1cc1018d0aa..a33a7972f13 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46522909713..0a2bbc17473 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-16 Marek Polacek PR c++/85827 diff --git a/gcc/testsuite/gfortran.dg/pr91471.f90 b/gcc/testsuite/gfortran.dg/pr91471.f90 new file mode 100644 index 00000000000..fa798444c1d --- /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