Fortran: improve error recovery for invalid coarray function declarations
gcc/fortran/ChangeLog: PR fortran/104210 * arith.cc (eval_intrinsic): Avoid NULL pointer dereference. (gfc_zero_size_array): Likewise. gcc/testsuite/ChangeLog: PR fortran/104210 * gfortran.dg/pr104210.f90: New test.
This commit is contained in:
parent
d46685b040
commit
892c7f03ae
@ -1489,6 +1489,9 @@ eval_intrinsic (gfc_intrinsic_op op,
|
||||
int unary;
|
||||
arith rc;
|
||||
|
||||
if (!op1)
|
||||
return NULL;
|
||||
|
||||
gfc_clear_ts (&temp.ts);
|
||||
|
||||
switch (op)
|
||||
@ -1703,11 +1706,11 @@ eval_type_intrinsic0 (gfc_intrinsic_op iop, gfc_expr *op)
|
||||
|
||||
/* Return nonzero if the expression is a zero size array. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
gfc_zero_size_array (gfc_expr *e)
|
||||
{
|
||||
if (e->expr_type != EXPR_ARRAY)
|
||||
return 0;
|
||||
if (e == NULL || e->expr_type != EXPR_ARRAY)
|
||||
return false;
|
||||
|
||||
return e->value.constructor == NULL;
|
||||
}
|
||||
|
15
gcc/testsuite/gfortran.dg/pr104210.f90
Normal file
15
gcc/testsuite/gfortran.dg/pr104210.f90
Normal file
@ -0,0 +1,15 @@
|
||||
! { dg-do compile }
|
||||
! { dg-options "-fcoarray=single" }
|
||||
! PR fortran/104210
|
||||
! Contributed by G.Steinmetz
|
||||
|
||||
function f() ! { dg-error "shall not be a coarray" }
|
||||
integer :: f[*]
|
||||
end
|
||||
program p
|
||||
interface
|
||||
function f() ! { dg-error "shall not be a coarray" }
|
||||
integer :: f[*]
|
||||
end
|
||||
end interface
|
||||
end
|
Loading…
Reference in New Issue
Block a user