From 8b4e5e711d9b2b979dcee445498a7f570ea49e2e Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 2 Oct 2019 17:01:30 +0000 Subject: [PATCH] re PR fortran/91943 (ICE in gfc_conv_constant_to_tree, at fortran/trans-const.c:370) 2019-10-02 Steven G. Kargl PR fortran/91943 * match.c (gfc_match_call): BOZ cannot be an actual argument in a subroutine reference. * resolve.c (resolve_function): BOZ cannot be an actual argument in a function reference. 2019-10-02 Steven G. Kargl PR fortran/91943 gfortran.dg/pr91943.f90 From-SVN: r276471 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/match.c | 10 ++++++++++ gcc/fortran/resolve.c | 15 +++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr91943.f90 | 7 +++++++ 5 files changed, 45 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr91943.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 51c393a..f225ff2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-10-02 Steven G. Kargl + + PR fortran/91943 + * match.c (gfc_match_call): BOZ cannot be an actual argument in + a subroutine reference. + * resolve.c (resolve_function): BOZ cannot be an actual argument in + a function reference. + 2019-10-01 Jan Hubicka * module.c (load_commons): Initialize flags to 0 to silecne diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 83b1189..4a31080 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4984,6 +4984,16 @@ gfc_match_call (void) goto syntax; } + /* Walk the argument list looking for invalid BOZ. */ + for (a = arglist; a; a = a->next) + if (a->expr && a->expr->ts.type == BT_BOZ) + { + gfc_error ("A BOZ literal constant at %L cannot appear as an actual " + "argument in a subroutine reference", &a->expr->where); + goto cleanup; + } + + /* If any alternate return labels were found, construct a SELECT statement that will jump to the right place. */ diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e8d0566..a792547 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -3242,6 +3242,21 @@ resolve_function (gfc_expr *expr) if (expr->expr_type != EXPR_FUNCTION) return t; + /* Walk the argument list looking for invalid BOZ. */ + if (expr->value.function.esym) + { + gfc_actual_arglist *a; + + for (a = expr->value.function.actual; a; a = a->next) + if (a->expr && a->expr->ts.type == BT_BOZ) + { + gfc_error ("A BOZ literal constant at %L cannot appear as an " + "actual argument in a function reference", + &a->expr->where); + return false; + } + } + temp = need_full_assumed_size; need_full_assumed_size = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d455ce6..3256a02 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-02 Steven G. Kargl + + PR fortran/91943 + gfortran.dg/pr91943.f90 + 2019-10-02 Jan Hubicka * g++.dg/tree-ssa/pr53844.C: Add -fno-inline-functions --param diff --git a/gcc/testsuite/gfortran.dg/pr91943.f90 b/gcc/testsuite/gfortran.dg/pr91943.f90 new file mode 100644 index 0000000..c2752c5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91943.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/91943 +! Code contributed by Gerhard Steinmetz +program p + print *, f(b'1001') ! { dg-error "cannot appear as an actual argument" } + call sub(b'1001') ! { dg-error "cannot appear as an actual argument" } +end -- 2.7.4