This is the mail archive of the 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]

Ping: Fix PR fortran/71688

Ping (this time also CCing fortran@gcc.gnu and Honza).

I really think this should be backported to 4.9 in time for the last



----- Original message from Martin Jambor <> -----

Date: Thu, 30 Jun 2016 11:13:17 +0200
From: Martin Jambor <>
To: GCC Patches <>
Subject: Fix PR fortran/71688


PR 71688 is about an ICE in cgraphunit.c caused by the fact that
Fortran FE creates two separate call-graph nodes for a single function
decl, if you are interested, complete backtraces leading to the point
of creating them are in bugzilla.

The intuitive fix, changing one of these points so that they call
cgraph::get_create rather than cgraph_node::create works and given the
comment just before the line also seems like the correct thing to do:

      /* Register this function with cgraph just far enough to get it
	 added to our parent's nested function list.
	 If there are static coarrays in this function, the nested _caf_init
	 function has already called cgraph_create_node, which also created
	 the cgraph node for this function.  */

It is interesting that the bug lurked so long there.  I have
bootstrapped and tested the patch below on x86_64-linux, is it OK for
trunk and (after a while) for all active release branches?



2016-06-29  Martin Jambor  <>

	PR fortran/71688
	* trans-decl.c (gfc_generate_function_code): Use get_create rather
	than create to get a call graph node.

	gfortran.dg/pr71688.f90: New test.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 2f5e434..0e68736 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -6336,7 +6336,7 @@ gfc_generate_function_code (gfc_namespace * ns)
 	 function has already called cgraph_create_node, which also created
 	 the cgraph node for this function.  */
       if (!has_coarray_vars || flag_coarray != GFC_FCOARRAY_LIB)
-	(void) cgraph_node::create (fndecl);
+	(void) cgraph_node::get_create (fndecl);
     cgraph_node::finalize_function (fndecl, true);
diff --git a/gcc/testsuite/gfortran.dg/pr71688.f90 b/gcc/testsuite/gfortran.dg/pr71688.f90
new file mode 100644
index 0000000..dbb6d18
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr71688.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+program p
+   call s
+   subroutine s
+      real :: x[*] = 1
+      block
+      end block
+      x = 2
+   end

----- End original message -----

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