return true;
}
-static bool
-invalid_null_arg (gfc_expr *x)
+bool
+gfc_invalid_null_arg (gfc_expr *x)
{
if (x->expr_type == EXPR_NULL)
{
int i;
bool t;
- if (invalid_null_arg (pointer))
+ if (gfc_invalid_null_arg (pointer))
return false;
attr1 = gfc_expr_attr (pointer);
if (target == NULL)
return true;
- if (invalid_null_arg (target))
+ if (gfc_invalid_null_arg (target))
return false;
if (target->expr_type == EXPR_VARIABLE || target->expr_type == EXPR_FUNCTION)
bool
gfc_check_kind (gfc_expr *x)
{
- if (invalid_null_arg (x))
+ if (gfc_invalid_null_arg (x))
return false;
if (gfc_bt_struct (x->ts.type) || x->ts.type == BT_CLASS)
if (!type_check (s, 0, BT_CHARACTER))
return false;
+ if (gfc_invalid_null_arg (s))
+ return false;
+
if (!kind_check (kind, 1, BT_INTEGER))
return false;
if (kind && !gfc_notify_std (GFC_STD_F2003, "%qs intrinsic "
bool
gfc_check_merge (gfc_expr *tsource, gfc_expr *fsource, gfc_expr *mask)
{
- if (invalid_null_arg (tsource))
+ if (gfc_invalid_null_arg (tsource))
return false;
- if (invalid_null_arg (fsource))
+ if (gfc_invalid_null_arg (fsource))
return false;
if (!same_type_check (tsource, 0, fsource, 1))
{
gfc_array_ref *ar;
- if (invalid_null_arg (source))
+ if (gfc_invalid_null_arg (source))
return false;
if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
bool
gfc_check_sizeof (gfc_expr *arg)
{
- if (invalid_null_arg (arg))
+ if (gfc_invalid_null_arg (arg))
return false;
if (arg->ts.type == BT_PROCEDURE)
bool
gfc_check_spread (gfc_expr *source, gfc_expr *dim, gfc_expr *ncopies)
{
- if (invalid_null_arg (source))
+ if (gfc_invalid_null_arg (source))
return false;
if (source->rank >= GFC_MAX_DIMENSIONS)
size_t source_size;
size_t result_size;
- if (invalid_null_arg (source))
+ if (gfc_invalid_null_arg (source))
return false;
/* SOURCE shall be a scalar or array of any type. */
if (mold->ts.type == BT_BOZ && illegal_boz_arg (mold))
return false;
- if (invalid_null_arg (mold))
+ if (gfc_invalid_null_arg (mold))
return false;
/* MOLD shall be a scalar or array of any type. */
if (!type_check (x, 0, BT_CHARACTER))
return false;
+ if (gfc_invalid_null_arg (x))
+ return false;
+
if (!scalar_check (x, 0))
return false;
return false;
}
+ /* F2018, p. 328: An argument to an intrinsic procedure other than
+ ASSOCIATED, NULL, or PRESENT shall be a data object. An EXPR_NULL
+ is not a data object. */
+ if (actual->expr->expr_type == EXPR_NULL
+ && (!(sym->id == GFC_ISYM_ASSOCIATED
+ || sym->id == GFC_ISYM_NULL
+ || sym->id == GFC_ISYM_PRESENT)))
+ {
+ gfc_invalid_null_arg (actual->expr);
+ return false;
+ }
+
/* If the formal argument is INTENT([IN]OUT), check for definability. */
if (formal->intent == INTENT_INOUT || formal->intent == INTENT_OUT)
{
--- /dev/null
+! { dg-do compile }
+! PR fortran/95544 - ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494
+
+program test
+ character(:), allocatable :: z
+ character(:), pointer :: p
+ character(1), pointer :: c
+ print *, adjustl (null(z)) ! { dg-error "is not permitted as actual argument" }
+ print *, adjustr (null(z)) ! { dg-error "is not permitted as actual argument" }
+ print *, len (null(p)) ! { dg-error "is not permitted as actual argument" }
+ print *, len (null(z)) ! { dg-error "is not permitted as actual argument" }
+ print *, len_trim(null(c)) ! { dg-error "is not permitted as actual argument" }
+ print *, len_trim(null(z)) ! { dg-error "is not permitted as actual argument" }
+ print *, trim (null(z)) ! { dg-error "is not permitted as actual argument" }
+end