From c078c9f4478d6d27dd8d2b7f8a6f8e9a5849dc47 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 23 Jul 2019 23:02:07 +0000 Subject: [PATCH] re PR fortran/54072 (BOZ with -std=f2008: wrongly accepted to TRANSFER/ABS/...; two BOZ not rejected for IOR/IEOR/IAND) 2019-07-23 Steven G. Kargl 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 PR fortran/54072 * gfortran.dg/illegal_boz_arg_1.f90: New tests. From-SVN: r273748 --- gcc/fortran/ChangeLog | 10 ++++++ gcc/fortran/check.c | 33 +++++++++++++++---- gcc/fortran/primary.c | 1 - gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/illegal_boz_arg_1.f90 | 9 +++++ 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/illegal_boz_arg_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7cac31028e6..622f5762a84 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2019-07-23 Steven G. Kargl + + 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 * arith.c (gfc_convert_integer, gfc_convert_real, gfc_convert_complex): diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 1543f136699..376edd3ae83 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -35,10 +35,10 @@ along with GCC; see the file COPYING3. If not see #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) @@ -54,6 +54,20 @@ 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 @@ -2202,8 +2216,6 @@ gfc_check_co_sum (gfc_expr *a, gfc_expr *result_image, gfc_expr *stat, 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; @@ -5894,6 +5906,12 @@ gfc_check_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size) 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) @@ -7125,6 +7143,9 @@ gfc_check_storage_size (gfc_expr *a, gfc_expr *kind) return false; } + if (a->ts.type == BT_BOZ && illegal_boz_arg (a)) + return false; + if (kind == NULL) return true; diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index da524e9b714..1cc1018d0aa 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -494,7 +494,6 @@ match_boz_constant (gfc_expr **result) 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))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 43e7862c8f2..342ba982c75 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-23 Steven G. Kargl + + PR fortran/54072 + * gfortran.dg/illegal_boz_arg_1.f90: New tests. + 2019-07-23 Steven G. Kargl * gfortran.dg/achar_5.f90: Fix for new BOZ handling. diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_1.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_1.f90 new file mode 100644 index 00000000000..8a79a5219d2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_1.f90 @@ -0,0 +1,9 @@ +! { 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 -- 2.30.2