PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690

Do not dereference NULL pointer when querying array shape of possibly
improperly delared variable.

gcc/fortran/
	PR fortran/95340
	* match.c (gfc_match_select_rank): Do not dereference NULL pointer.
This commit is contained in:
Harald Anlauf 2020-06-28 16:24:15 +02:00
parent 06ed4aae1c
commit b62cac6d92
2 changed files with 12 additions and 1 deletions

View File

@ -6695,7 +6695,8 @@ gfc_match_select_rank (void)
if (expr1->symtree)
{
sym = expr1->symtree->n.sym;
as = sym->ts.type == BT_CLASS ? CLASS_DATA (sym)->as : sym->as;
as = (sym->ts.type == BT_CLASS
&& CLASS_DATA (sym)) ? CLASS_DATA (sym)->as : sym->as;
}
if (expr1->expr_type != EXPR_VARIABLE

View File

@ -0,0 +1,10 @@
! { dg-do compile }
! PR fortran/95340 - ICE in gfc_match_select_rank, at fortran/match.c:6690
program p
type t
end type t
class(t) :: z ! { dg-error "must be dummy, allocatable or pointer" }
select rank (z) ! { dg-error "must be an assumed rank variable" }
end select ! { dg-error "Expecting END PROGRAM" }
end