This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] PR34848 (ICE, 4.3 regression) Fix absent optional character argument


The following patch was approved by Jerry on IRC.

Calling an array-returning function where an optional character argument
was absent gave an ICE.

Since the function returns an array, need_interface_mapping is TRUE.
The actual argument expression is "e". The case "e == NULL" is
treated earlier in the file - including passing the character length
"0".

Calling gfc_add_interface_mapping with e == NULL somehow causes problems
in the middle end.

Build and reg-tested on x86-64-linux.
And committed as Rev. 131876.

Tobias
2008-01-26  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34848
	* trans-expr.c (gfc_conv_function_call): Don't call
	gfc_add_interface_mapping if the expression is NULL.

2008-01-26  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34848
	* gfortran.dg/missing_optional_dummy_5.f90: New.

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(Revision 131874)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -2506,7 +2506,7 @@ gfc_conv_function_call (gfc_se * se, gfc
 	    }
 	}
 
-      if (fsym && need_interface_mapping)
+      if (fsym && need_interface_mapping && e)
 	gfc_add_interface_mapping (&mapping, fsym, &parmse, e);
 
       gfc_add_block_to_block (&se->pre, &parmse.pre);
Index: gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90	(Revision 0)
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/34848
+! 
+! This was before giving an ICE; additionally
+! the "0" for the string size of the absent optional
+! argument was missing.
+!
+module krmod
+contains
+ subroutine doit()
+   implicit none
+    real :: doit1(2)
+    doit1 = tm_doit()
+   return
+ end subroutine doit
+ function tm_doit(genloc)
+   implicit none
+   character, optional  :: genloc
+   real :: tm_doit(2)
+   tm_doit = 42.0 
+ end function tm_doit
+end module krmod
+
+! { dg-final { scan-tree-dump " tm_doit \\(&parm.7, 0B, 0\\);" "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
+! { dg-final { cleanup-modules "pr22146" } }
+

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