This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran, committed] Fix adding type to missing_arg_type (cf. PR 34848)


For absent optional arguments, the type of the argument was not set for missing_arg_type if there was no argument (i.e. all absent). The reason is that at the beginning of the function

actual = *ap;

Then *ap was updated later but the last loop did not use the new *ap but the obsolete actual (which is a NULL pointer).

Consequence: We pass also a length for absent character actual arguments in trans-expr.c.


Committed as Rev. 131738. The actual, rejects-valid regression in the PR is not fixed by this patch.


Tobias

Index: fortran/interface.c
===================================================================
--- fortran/interface.c (Revision 131737)
+++ fortran/interface.c (Arbeitskopie)
@@ -2147,7 +2147,7 @@ compare_actual_formal (gfc_actual_arglis
    *ap = new[0];

  /* Note the types of omitted optional arguments.  */
-  for (a = actual, f = formal; a; a = a->next, f = f->next)
+  for (a = *ap, f = formal; a; a = a->next, f = f->next)
    if (a->expr == NULL && a->label == NULL)
      a->missing_arg_type = f->sym->ts.type;

Index: fortran/ChangeLog
===================================================================
--- fortran/ChangeLog   (Revision 131737)
+++ fortran/ChangeLog   (Arbeitskopie)
@@ -1,5 +1,11 @@
2008-01-22  Tobias Burnus  <burnus@net-b.de>

+       PR fortran/34848
+       * interface.c (compare_actual_formal): Fix adding type
+       to missing_arg_type for absent optional arguments.
+
+2008-01-22  Tobias Burnus  <burnus@net-b.de>
+
       PR fortran/34907
       * parse.c (parse_spec): Change = into ==.

Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (Revision 131737)
+++ testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2008-01-22  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34848
+       * gfortran.dg/missing_optional_dummy_4.f90
+
2008-01-22  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

       * gcc.dg/vect/vect-ifcvt-9.c: Use inline.
Index: testsuite/gfortran.dg/missing_optional_dummy_4.f90
===================================================================
--- testsuite/gfortran.dg/missing_optional_dummy_4.f90  (Revision 0)
+++ testsuite/gfortran.dg/missing_optional_dummy_4.f90  (Revision 0)
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/34848
+!
+! The "0" for the string size of the absent optional
+! argument was missing.
+!
+module krmod
+contains
+ subroutine doit()
+   implicit none
+    real :: doit1
+    doit1 = tm_doit()
+   return
+ end subroutine doit
+ function tm_doit(genloc)
+   implicit none
+   character, optional  :: genloc
+   real :: tm_doit
+   tm_doit = 42.0
+ end function tm_doit
+end module krmod
+
+! { dg-final { scan-tree-dump " tm_doit \\(0B, 0\\);" "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
+! { dg-final { cleanup-modules "krmod" } }
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]