Fortran: fix error recovery for invalid constructor
gcc/fortran/ChangeLog: PR fortran/102520 * array.c (expand_constructor): Do not dereference NULL pointer. gcc/testsuite/ChangeLog: PR fortran/102520 * gfortran.dg/pr102520.f90: New test.
This commit is contained in:
parent
a672a22582
commit
5e2adfeed2
2 changed files with 15 additions and 0 deletions
|
@ -1798,6 +1798,9 @@ expand_constructor (gfc_constructor_base base)
|
|||
|
||||
e = c->expr;
|
||||
|
||||
if (e == NULL)
|
||||
return false;
|
||||
|
||||
if (empty_constructor)
|
||||
empty_ts = e->ts;
|
||||
|
||||
|
|
12
gcc/testsuite/gfortran.dg/pr102520.f90
Normal file
12
gcc/testsuite/gfortran.dg/pr102520.f90
Normal file
|
@ -0,0 +1,12 @@
|
|||
! { dg-do compile }
|
||||
! PR fortran/102520 - ICE in expand_constructor, at fortran/array.c:1802
|
||||
|
||||
program p
|
||||
type t
|
||||
end type
|
||||
type(t), parameter :: a(4) = shape(1) ! { dg-error "Incompatible" }
|
||||
type(t), parameter :: b(2,2) = reshape(a,[2,2]) ! { dg-error "Incompatible" }
|
||||
type(t), parameter :: c(2,2) = transpose(b) ! { dg-error "Unclassifiable" }
|
||||
end
|
||||
|
||||
! { dg-error "Different shape for array assignment" " " { target *-*-* } 7 }
|
Loading…
Add table
Reference in a new issue