From ac193ee73ca85cae3e7c761f1bda491620b4ccab Mon Sep 17 00:00:00 2001 From: Louis Krupp Date: Fri, 7 Oct 2016 02:02:13 +0000 Subject: [PATCH] 2016_10-06 Louis Krupp PR fortran/57910 * gfortran.dg/pr57910.f90: New test. 2016-10-05 Louis Krupp PR fortran/57910 * trans-expr.c (gfc_add_interface_mapping): Don't try to dereference call-by-value scalar argument From-SVN: r240850 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-expr.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr57910.f90 | 26 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr57910.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2bab7b3110b..874779b92dd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-10-05 Louis Krupp + + PR fortran/57910 + * trans-expr.c (gfc_add_interface_mapping): Don't try to + dereference call-by-value scalar argument + 2016-10-05 Steven G. Kargl PR fortran/58991 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index a82178835ac..1de2818a6b2 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4009,6 +4009,10 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, if (sym->attr.flavor == FL_PROCEDURE) value = se->expr; + /* If the argument is a pass-by-value scalar, use the value as is. */ + else if (!sym->attr.dimension && sym->attr.value) + value = se->expr; + /* If the argument is either a string or a pointer to a string, convert it to a boundless character type. */ else if (!sym->attr.dimension && sym->ts.type == BT_CHARACTER) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9aee1b289ea..18c1a17242f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016_10-06 Louis Krupp + + PR fortran/57910 + * gfortran.dg/pr57910.f90: New test. + 2016-10-06 Jakub Jelinek * g++.dg/cpp1z/has-unique-obj-representations1.C: New test. diff --git a/gcc/testsuite/gfortran.dg/pr57910.f90 b/gcc/testsuite/gfortran.dg/pr57910.f90 new file mode 100644 index 00000000000..c3666a6fcd8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr57910.f90 @@ -0,0 +1,26 @@ +! { dg-do run } +program strtest + + implicit none + + character(len=:), allocatable:: my_str + + integer, parameter :: slen_init = 7 + integer :: slen = slen_init + + my_str = fstr(slen) + if (slen /= slen_init .or. len(my_str) /= slen .or. my_str /= ' ') then + call abort + endif + +contains + + function fstr(strlen) + integer, value :: strlen + character(len=strlen)::fstr + + strlen = 17 ! Make sure strlen was really passed by value + fstr = ' ' + end function fstr + +end program strtest -- 2.30.2