Patchwork [Ada] Fix crash on recursive call to function with Out parameter

login
register
mail settings
Submitter Eric Botcazou
Date July 3, 2012, 8:59 a.m.
Message ID <201207031059.26348.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/168742/
State New
Headers show

Comments

Eric Botcazou - July 3, 2012, 8:59 a.m.
The compiler crashes on the recursive call to a function with an In-Out or Out 
parameter passed by copy, in Ada 2012 mode.

Tested on i586-suse-linux, applied on mainline and 4.7 branch.


2012-07-03  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Call_to_gnu): Robustify test for function case
	if the CICO mechanism is used.


2012-07-03  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/recursive_call.adb: New test.

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 189199)
+++ gcc-interface/trans.c	(working copy)
@@ -4084,7 +4084,7 @@  Call_to_gnu (Node_Id gnat_node, tree *gn
 
       /* The first entry is for the actual return value if this is a
 	 function, so skip it.  */
-      if (TREE_VALUE (gnu_cico_list) == void_type_node)
+      if (function_call)
 	gnu_cico_list = TREE_CHAIN (gnu_cico_list);
 
       if (Nkind (Name (gnat_node)) == N_Explicit_Dereference)
@@ -4188,8 +4188,7 @@  Call_to_gnu (Node_Id gnat_node, tree *gn
 	 return value from it and update the return type.  */
       if (TYPE_CI_CO_LIST (gnu_subprog_type))
 	{
-	  tree gnu_elmt = value_member (void_type_node,
-					TYPE_CI_CO_LIST (gnu_subprog_type));
+	  tree gnu_elmt = TYPE_CI_CO_LIST (gnu_subprog_type);
 	  gnu_call = build_component_ref (gnu_call, NULL_TREE,
 					  TREE_PURPOSE (gnu_elmt), false);
 	  gnu_result_type = TREE_TYPE (gnu_call);