diff mbox

[Ada] Fix ICE on VMS valued procedure

Message ID 201308132120.55353.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Aug. 13, 2013, 7:20 p.m. UTC
This fixes an ICE on a call to a valued procedure that takes a converted 
integer as actual parameter passed by reference.

Tested on x86_64-suse-linux, applied on the mainline.


2013-08-13  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Call_to_gnu): Deal with specific conditional
	expressions for misaligned actual parameters.


2013-08-13  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/valued_proc.adb: New test.
	* gnat.dg/valued_proc_pkg.ads: New helper.
diff mbox

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 201692)
+++ gcc-interface/trans.c	(working copy)
@@ -4022,9 +4022,19 @@  Call_to_gnu (Node_Id gnat_node, tree *gn
 	  /* Set up to move the copy back to the original if needed.  */
 	  if (!in_param)
 	    {
-	      gnu_stmt = build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_orig,
-					  gnu_temp);
+	      /* If the original is a COND_EXPR whose first arm isn't meant to
+		 be further used, just deal with the second arm.  This is very
+		 likely the conditional expression built for a check.  */
+	      if (TREE_CODE (gnu_orig) == COND_EXPR
+		  && TREE_CODE (TREE_OPERAND (gnu_orig, 1)) == COMPOUND_EXPR
+		  && integer_zerop
+		     (TREE_OPERAND (TREE_OPERAND (gnu_orig, 1), 1)))
+		gnu_orig = TREE_OPERAND (gnu_orig, 2);
+
+	      gnu_stmt
+		= build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_orig, gnu_temp);
 	      set_expr_location_from_node (gnu_stmt, gnat_node);
+
 	      append_to_statement_list (gnu_stmt, &gnu_after_list);
 	    }
 	}