diff mbox

[Ada] Fix ICE on loop at -O3

Message ID 4562296.0Pgz1dnq1l@polaris
State New
Headers show

Commit Message

Eric Botcazou March 16, 2015, 9:54 a.m. UTC
This fixes a regression present on all active branches at -O3, caused by a 
call to fold_convert with an aggregate type.

Tested on x86_64-suse-linux, applied on all active branches.


2015-03-16  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/utils2.c (gnat_invariant_expr): Return null if the type
	of the expression ends up being composite.


2015-03-16  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/loop_optimization18.ad[sb]: New test.
	* gnat.dg/loop_optimization18_pkg.ads: New helper.
diff mbox

Patch

Index: gcc-interface/utils2.c
===================================================================
--- gcc-interface/utils2.c	(revision 221407)
+++ gcc-interface/utils2.c	(working copy)
@@ -2805,6 +2805,12 @@  gnat_invariant_expr (tree expr)
       expr = remove_conversions (expr, false);
     }
 
+  /* We are only interested in scalar types at the moment and, even if we may
+     have gone through padding types in the above loop, we must be back to a
+     scalar value at this point.  */
+  if (AGGREGATE_TYPE_P (TREE_TYPE (expr)))
+    return NULL_TREE;
+
   if (TREE_CONSTANT (expr))
     return fold_convert (type, expr);