Fortran - ICE in gfc_check_do_variable, at fortran/parse.c:4446
Avoid NULL pointer dereferences during error recovery. gcc/fortran/ChangeLog: PR fortran/95501 PR fortran/95502 * expr.c (gfc_check_pointer_assign): Avoid NULL pointer dereference. * match.c (gfc_match_pointer_assignment): Likewise. * parse.c (gfc_check_do_variable): Avoid comparison with NULL symtree. gcc/testsuite/ChangeLog: PR fortran/95501 PR fortran/95502 * gfortran.dg/pr95502.f90: New test.
This commit is contained in:
parent
bdfc1207bd
commit
72e3d92178
@ -1683,10 +1683,21 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 1
|
||||
cons = gfc_constructor_lookup (base, limit);
|
||||
gcc_assert (cons);
|
||||
gfc_constructor_append_expr (&expr->value.constructor,
|
||||
gfc_copy_expr (cons->expr), NULL);
|
||||
#else
|
||||
cons = gfc_constructor_lookup (base, limit);
|
||||
if (cons)
|
||||
gfc_constructor_append_expr (&expr->value.constructor,
|
||||
gfc_copy_expr (cons->expr), NULL);
|
||||
else
|
||||
{
|
||||
t = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mpz_clear (ptr);
|
||||
@ -3476,6 +3487,7 @@ gfc_specification_expr (gfc_expr *e)
|
||||
{
|
||||
gfc_error ("Expression at %L must be of INTEGER type, found %s",
|
||||
&e->where, gfc_basic_typename (e->ts.type));
|
||||
gfc_clear_ts (&e->ts);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3815,6 +3827,9 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
|
||||
int proc_pointer;
|
||||
bool same_rank;
|
||||
|
||||
if (!lvalue->symtree)
|
||||
return false;
|
||||
|
||||
lhs_attr = gfc_expr_attr (lvalue);
|
||||
if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer)
|
||||
{
|
||||
|
@ -1409,7 +1409,7 @@ gfc_match_pointer_assignment (void)
|
||||
gfc_matching_procptr_assignment = 0;
|
||||
|
||||
m = gfc_match (" %v =>", &lvalue);
|
||||
if (m != MATCH_YES)
|
||||
if (m != MATCH_YES || !lvalue->symtree)
|
||||
{
|
||||
m = MATCH_NO;
|
||||
goto cleanup;
|
||||
|
@ -4588,6 +4588,9 @@ gfc_check_do_variable (gfc_symtree *st)
|
||||
{
|
||||
gfc_state_data *s;
|
||||
|
||||
if (!st)
|
||||
return 0;
|
||||
|
||||
for (s=gfc_state_stack; s; s = s->previous)
|
||||
if (s->do_variable == st)
|
||||
{
|
||||
|
8
gcc/testsuite/gfortran.dg/pr95502.f90
Normal file
8
gcc/testsuite/gfortran.dg/pr95502.f90
Normal file
@ -0,0 +1,8 @@
|
||||
! { dg-do compile }
|
||||
! PR fortran/95502 - ICE in gfc_check_do_variable, at fortran/parse.c:4446
|
||||
|
||||
program p
|
||||
integer, pointer :: z
|
||||
nullify (z%kind) ! { dg-error "in variable definition context" }
|
||||
z%kind => NULL() ! { dg-error "constant expression" }
|
||||
end
|
Loading…
Reference in New Issue
Block a user