Possible patch for fortran/57910 (correct patch attached)
Louis Krupp
louis.krupp@zoho.com
Thu Oct 6 17:12:00 GMT 2016
PR fortran/57910
* trans-expr.c (gfc_add_interface_mapping): Don't try to
dereference call-by-value scalar argument.
The patch seems to work without breaking other tests.
Louis Krupp
-------------- next part --------------
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (revision 240824)
+++ gcc/fortran/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2016-10-05 Louis Krupp <louis.krupp@zoho.com>
+
+ 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 <kargls@gcc.gnu.org>
PR fortran/58991
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 240824)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2016_10-05 Louis Krupp <louis.krupp@zoho.com>
+
+ PR fortran/57910
+ * gfortran.dg/pr57910.f90: New test.
+
2016-10-06 Marek Polacek <polacek@redhat.com>
* g++.dg/cpp1z/init-statement9.C: New test.
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 240824)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -4009,6 +4009,10 @@ gfc_add_interface_mapping (gfc_interface_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)
Index: gcc/testsuite/gfortran.dg/pr57910.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr57910.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr57910.f90 (working copy)
@@ -0,0 +1,29 @@
+! { dg-do run }
+program strtest
+
+ implicit none
+
+ interface
+ end interface
+
+ 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
More information about the Fortran
mailing list