mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
Fortran: improve error recovery on invalid array section
gcc/fortran/ChangeLog: PR fortran/104849 * expr.cc (find_array_section): Avoid NULL pointer dereference on invalid array section. gcc/testsuite/ChangeLog: PR fortran/104849 * gfortran.dg/pr104849.f90: New test.
This commit is contained in:
@@ -1594,7 +1594,9 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
|
||||
{
|
||||
if ((begin && begin->expr_type != EXPR_CONSTANT)
|
||||
|| (finish && finish->expr_type != EXPR_CONSTANT)
|
||||
|| (step && step->expr_type != EXPR_CONSTANT))
|
||||
|| (step && step->expr_type != EXPR_CONSTANT)
|
||||
|| (!begin && !lower)
|
||||
|| (!finish && !upper))
|
||||
{
|
||||
t = false;
|
||||
goto cleanup;
|
||||
|
||||
9
gcc/testsuite/gfortran.dg/pr104849.f90
Normal file
9
gcc/testsuite/gfortran.dg/pr104849.f90
Normal file
@@ -0,0 +1,9 @@
|
||||
! { dg-do compile }
|
||||
! PR fortran/104849 - ICE in find_array_section
|
||||
! Contributed by G.Steinmetz
|
||||
|
||||
program p
|
||||
integer, parameter :: a(:) = [1, 2] ! { dg-error "deferred shape" }
|
||||
integer :: x(2)
|
||||
data x /a(:)/ ! { dg-error "Invalid" }
|
||||
end
|
||||
Reference in New Issue
Block a user