PR fortran/96086 - ICE in gfc_match_select_rank, at fortran/match.c:6645
Handle NULL pointer dereference on SELECT RANK with an invalid assumed-rank array declaration. gcc/fortran/ PR fortran/96086 * match.c (gfc_match_select_rank): Catch NULL pointer dereference. * resolve.c (resolve_assoc_var): Catch NULL pointer dereference that may occur after an illegal declaration.
This commit is contained in:
parent
2b6d99468d
commit
8a0b69f0b0
3 changed files with 14 additions and 3 deletions
|
@ -6647,7 +6647,8 @@ gfc_match_select_rank (void)
|
|||
if (expr2->symtree)
|
||||
{
|
||||
sym2 = expr2->symtree->n.sym;
|
||||
as = sym2->ts.type == BT_CLASS ? CLASS_DATA (sym2)->as : sym2->as;
|
||||
as = (sym2->ts.type == BT_CLASS
|
||||
&& CLASS_DATA (sym2)) ? CLASS_DATA (sym2)->as : sym2->as;
|
||||
}
|
||||
|
||||
if (expr2->expr_type != EXPR_VARIABLE
|
||||
|
@ -6659,7 +6660,7 @@ gfc_match_select_rank (void)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (expr2->ts.type == BT_CLASS)
|
||||
if (expr2->ts.type == BT_CLASS && CLASS_DATA (sym2))
|
||||
{
|
||||
copy_ts_from_selector_to_associate (expr1, expr2);
|
||||
|
||||
|
|
|
@ -9012,7 +9012,9 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target)
|
|||
if (as->corank != 0)
|
||||
sym->attr.codimension = 1;
|
||||
}
|
||||
else if (sym->ts.type == BT_CLASS && (!CLASS_DATA (sym)->as || sym->assoc->rankguessed))
|
||||
else if (sym->ts.type == BT_CLASS
|
||||
&& CLASS_DATA (sym)
|
||||
&& (!CLASS_DATA (sym)->as || sym->assoc->rankguessed))
|
||||
{
|
||||
if (!CLASS_DATA (sym)->as)
|
||||
CLASS_DATA (sym)->as = gfc_get_array_spec ();
|
||||
|
|
8
gcc/testsuite/gfortran.dg/pr96086.f90
Normal file
8
gcc/testsuite/gfortran.dg/pr96086.f90
Normal file
|
@ -0,0 +1,8 @@
|
|||
! { dg-do compile }
|
||||
! PR fortran/96086 - ICE in gfc_match_select_rank, at fortran/match.c:6645
|
||||
|
||||
subroutine s
|
||||
class(*) :: x(..) ! { dg-error "Assumed-rank array" }
|
||||
select rank (y => x) ! { dg-error "CLASS variable" }
|
||||
end select
|
||||
end
|
Loading…
Add table
Reference in a new issue