From 1af734911a08c4cb41046cb0e0ffe2206dcdf142 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Wed, 31 Jan 2018 20:28:35 +0000 Subject: [PATCH] re PR fortran/84088 ([nvptx] libgomp.oacc-fortran/declare-*.f90 execution fails) 2018-01-31 Paul Thomas PR fortran/84088 * trans-expr.c (gfc_conv_procedure_call): If the parm expr is an address expression passed to an assumed rank dummy, convert to an indirect reference. 2018-01-31 Paul Thomas PR fortran/84088 * gfortran.dg/pr84088.f90 : New test. From-SVN: r257262 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/trans-expr.c | 6 ++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr84088.f90 | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr84088.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 028f4be6e0f..70e1494b75a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-01-31 Paul Thomas + + PR fortran/84088 + * trans-expr.c (gfc_conv_procedure_call): If the parm expr is + an address expression passed to an assumed rank dummy, convert + to an indirect reference. + 2018-01-31 Thomas Koenig * dump-parse-tree.c (write_proc): Use sym_name (which may diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index eb359768c69..7f790e76a85 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -5325,10 +5325,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && fsym->ts.type != BT_CLASS && e->expr_type != EXPR_NULL) { tmp = parmse.expr; - if (TREE_CODE (tmp) == ADDR_EXPR - && (POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (tmp, 0))) - || e->expr_type == EXPR_CONSTANT)) - tmp = TREE_OPERAND (tmp, 0); + if (TREE_CODE (tmp) == ADDR_EXPR) + tmp = build_fold_indirect_ref_loc (input_location, tmp); parmse.expr = gfc_conv_scalar_to_descriptor (&parmse, tmp, fsym->attr); parmse.expr = gfc_build_addr_expr (NULL_TREE, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57fbb47f732..70cba83b6e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-31 Paul Thomas + + PR fortran/84088 + * gfortran.dg/pr84088.f90 : New test. + 2018-01-31 Vladimir Makarov PR target/82444 diff --git a/gcc/testsuite/gfortran.dg/pr84088.f90 b/gcc/testsuite/gfortran.dg/pr84088.f90 new file mode 100644 index 00000000000..36704afa151 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr84088.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! +! Test of fix for case in comment #7 of PR84088. +! +! Contributed by Tom de Vries +! +implicit none + integer(kind=4) z + + call foo (z) + +contains + subroutine foo (a) + type (*), dimension (..), contiguous :: a + integer(kind = 4) :: i + if(sizeof (a) .ne. sizeof (i)) call abort + end subroutine foo + +end program -- 2.30.2