diff mbox

[Ada] Fix internal error on call taking empty array Out parameter

Message ID 2908255.Z6tyVkJHnX@polaris
State New
Headers show

Commit Message

Eric Botcazou Dec. 10, 2015, 2:06 p.m. UTC
This is a regression present on the mainline only, for a pathological case 
where an empty array is passed as Out parameter to a procedure, but the code 
is actually never executed because it's inside an empty loop...

Tested on x86-64/Linux, applied on the mainline.


2015-12-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Call_to_gnu): Remove guard for NULL_EXPR.
	* gcc-interface/utils2.c (gnat_rewrite_reference) <ERROR_MARK>: Return
	the reference unmodified.
	<NULL_EXPR>: New case.  Likewise.


2015-12-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/array25.adb: New test.
	* gnat.dg/array25_pkg.ad[sb]: New helper.
diff mbox

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 231498)
+++ gcc-interface/trans.c	(working copy)
@@ -4407,9 +4407,7 @@  Call_to_gnu (Node_Id gnat_node, tree *gn
       /* If it's possible we may need to use this expression twice, make sure
 	 that any side-effects are handled via SAVE_EXPRs; likewise if we need
 	 to force side-effects before the call.  */
-      if (Ekind (gnat_formal) != E_In_Parameter
-	  && !is_by_ref_formal_parm
-	  && TREE_CODE (gnu_name) != NULL_EXPR)
+      if (Ekind (gnat_formal) != E_In_Parameter && !is_by_ref_formal_parm)
 	{
 	  tree init = NULL_TREE;
 	  gnu_name = gnat_stabilize_reference (gnu_name, true, &init);
Index: gcc-interface/utils2.c
===================================================================
--- gcc-interface/utils2.c	(revision 231498)
+++ gcc-interface/utils2.c	(working copy)
@@ -2733,7 +2733,8 @@  gnat_rewrite_reference (tree ref, rewrit
       break;
 
     case ERROR_MARK:
-      return error_mark_node;
+    case NULL_EXPR:
+      return ref;
 
     default:
       gcc_unreachable ();