Commit 687147ab by Harald Anlauf

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.

(cherry picked from commit b62cac6d92ff251213753475b69ec0b269cb7fae)
parent e3942f91
...@@ -6695,7 +6695,8 @@ gfc_match_select_rank (void) ...@@ -6695,7 +6695,8 @@ gfc_match_select_rank (void)
if (expr1->symtree) if (expr1->symtree)
{ {
sym = expr1->symtree->n.sym; 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 if (expr1->expr_type != EXPR_VARIABLE
......
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment