> I suggest to re-instantiate the canonical type checks for the aggregate type
> case.

OK, thanks, this fixes all the known ICEs so far.

Tested on x86_64-suse-linux, OK for the mainline?


2015-11-03  Eric Botcazou  <ebotca...@adacore.com>

        * gimple-expr.c (useless_type_conversion_p): Reinstate type canonical
        check for aggregate types and beef up comment for mode check.


2015-11-03  Eric Botcazou  <ebotca...@adacore.com>

        * gnat.dg/discr45.adb: Only compile the test.

-- 
Eric Botcazou
Index: gimple-expr.c
===================================================================
--- gimple-expr.c	(revision 229616)
+++ gimple-expr.c	(working copy)
@@ -84,7 +84,15 @@ useless_type_conversion_p (tree outer_ty
   if (inner_type == outer_type)
     return true;
 
-  /* Changes in machine mode are never useless conversions unless.  */
+  /* For aggregate types, if we know the canonical types, compare them.  This
+     is important for the remapping of variably-modified types.  */
+  if (AGGREGATE_TYPE_P (inner_type)
+      && TYPE_CANONICAL (inner_type)
+      && TYPE_CANONICAL (inner_type) == TYPE_CANONICAL (outer_type))
+    return true;
+
+  /* Changes in machine mode are never useless conversions because the RTL
+     middle-end expects explicit conversions between modes.  */
   if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type))
     return false;
 
Index: testsuite/gnat.dg/discr45.adb
===================================================================
--- testsuite/gnat.dg/discr45.adb	(revision 229630)
+++ testsuite/gnat.dg/discr45.adb	(working copy)
@@ -1,4 +1,4 @@
--- { dg-do run }
+-- { dg-do compile }
 -- { dg-options "-O2 -gnatws" }
 
 procedure Discr45 is

Reply via email to