Hi all,

the following patch fixes an issue with a multiple decl for procedures with procedure dummy arguments. Without the patch, multiple declarations are generated, which causes link failures ("euler" is optimized away) with -fwhole-program. (Thanks goes to Richard for spotting the problem with gfortran.dg/cray_pointers_8.f90.)

I have no idea why there should be a problem with inlining (cf. deleted comment), but removing that part did not give any test suite failure (check-gfortran + libgomp's check). Additionally, I have build and run the Polyhedron testsuite with "-march=native -ffast-math -funroll-loops -O3 -fno-protect-parens -finline-limit=400 -fwhole-program".

Build and tested on x86-64-linux.
OK for the trunk?

Tobias

PS: I have not created a test case; you think it should be added, one can copy gfortran.dg/cray_pointers_8.f90 and add a version with dg-options "-fwhole-file".
2011-05-15  Tobias Burnus  <bur...@net-b.de>

	PR fortran/48624
	* trans-decl.c (gfc_get_extern_function_decl): Fix decl
	for external procedures with proc arguments.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 784dfc8..866720f 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1527,7 +1527,6 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
   tree name;
   tree mangled_name;
   gfc_gsymbol *gsym;
-  bool proc_formal_arg;
 
   if (sym->backend_decl)
     return sym->backend_decl;
@@ -1544,27 +1543,10 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
      return the backend_decl.  */
   gsym =  gfc_find_gsymbol (gfc_gsym_root, sym->name);
 
-  /* Do not use procedures that have a procedure argument because this
-     can result in problems of multiple decls during inlining.  */
-  proc_formal_arg = false;
-  if (gsym && gsym->ns && gsym->ns->proc_name)
-    {
-      gfc_formal_arglist *formal = gsym->ns->proc_name->formal;
-      for (; formal; formal = formal->next)
-	{
-	  if (formal->sym && formal->sym->attr.flavor == FL_PROCEDURE)
-	    {
-	      proc_formal_arg = true;
-	      break;
-	    }
-	}
-    }
-
   if (gfc_option.flag_whole_file
 	&& (!sym->attr.use_assoc || sym->attr.if_source != IFSRC_DECL)
 	&& !sym->backend_decl
 	&& gsym && gsym->ns
-	&& !proc_formal_arg
 	&& ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION))
 	&& (gsym->ns->proc_name->backend_decl || !sym->attr.intrinsic))
     {

Reply via email to