+2019-07-23 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/54072
+ * check.c (gfc_invalid_boz): Fix comment.
+ (illegal_boz_arg): New function.
+ (gfc_check_transfer): Use to arguments.
+ (gfc_check_storage_size): Ditto.
+ (gfc_check_complex): Remove leftover comment from BOZ patch.
+ * primary.c (match_boz_constant): Remove leftover comment.
+
2019-07-23 Steven G. Kargl <kargl@gcc.gnu.org>
* arith.c (gfc_convert_integer, gfc_convert_real, gfc_convert_complex):
#include "target-memory.h"
/* A BOZ literal constant can appear in a limited number of contexts.
- gfc_invalid_boz() is a help function to simplify error/warning generation.
- Note, gfortran accepts the nonstandard 'X' for 'Z' the nonstandard
- suffix location. If -fallow-invalid-boz is used, then issue a warning;
- otherwise issue an error. */
+ gfc_invalid_boz() is a helper function to simplify error/warning
+ generation. gfortran accepts the nonstandard 'X' for 'Z', and gfortran
+ allows the BOZ indicator to appear as a suffix. If -fallow-invalid-boz
+ is used, then issue a warning; otherwise issue an error. */
bool
gfc_invalid_boz (const char *msg, locus *loc)
}
+/* Issue an error for an illegal BOZ argument. */
+static bool
+illegal_boz_arg (gfc_expr *x)
+{
+ if (x->ts.type == BT_BOZ)
+ {
+ gfc_error ("BOZ literal constant at %L cannot be an actual argument "
+ "to %qs", &x->where, gfc_current_intrinsic);
+ return true;
+ }
+
+ return false;
+}
+
/* Some precedures take two arguments such that both cannot be BOZ. */
static bool
bool
gfc_check_complex (gfc_expr *x, gfc_expr *y)
{
-
- /* FIXME BOZ. What to do with complex? */
if (!boz_args_check (x, y))
return false;
return false;
}
+ if (source->ts.type == BT_BOZ && illegal_boz_arg (source))
+ return false;
+
+ if (mold->ts.type == BT_BOZ && illegal_boz_arg (mold))
+ return false;
+
/* MOLD shall be a scalar or array of any type. */
if (mold->ts.type == BT_PROCEDURE
&& mold->symtree->n.sym->attr.subroutine == 1)
return false;
}
+ if (a->ts.type == BT_BOZ && illegal_boz_arg (a))
+ return false;
+
if (kind == NULL)
return true;
e->boz.str = XCNEWVEC (char, length + 1);
strncpy (e->boz.str, buffer, length);
- /* FIXME BOZ. */
if (!gfc_in_match_data ()
&& (!gfc_notify_std(GFC_STD_F2003, "BOZ used outside a DATA "
"statement at %L", &e->where)))
--- /dev/null
+! { dg-do compile }
+program foo
+ implicit none
+ integer :: i = 42
+ print *, storage_size(z'1234') ! { dg-error "cannot be an actual" }
+ print *, transfer(z'1234', i) ! { dg-error "cannot be an actual" }
+ print *, transfer(i, z'1234') ! { dg-error "cannot be an actual" }
+ print *, transfer(i, i, z'1234') ! { dg-error "must be INTEGER" }
+end program foo