diff mbox

Fix ICE in rtl_for_decl_init

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

Commit Message

Eric Botcazou Dec. 15, 2010, 11:52 a.m. UTC
Hi,

the attached testcase causes the compiler to ICE in rtl_for_decl_init when it 
is trying to generate debug info for the constant C.  The INIT expression is
  NOP_EXPR<const type> (VIEW_CONVERT_EXPR<type> (CONSTRUCTOR))
with type a scalar type.  The code in rtl_for_decl_init already knows how to 
skip aggregate types, but it doesn't see the inner CONSTRUCTOR.

Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?


2010-12-15  Eric Botcazou  <ebotcazou@adacore.com>

	* dwarf2out.c (rtl_for_decl_init): Strip no-op conversions off the
	initializer.  Skip view conversions from aggregate types.


2010-12-15  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/unchecked_convert8.ad[sb]: New test.

Comments

Jason Merrill Jan. 4, 2011, 10:17 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 167721)
+++ dwarf2out.c	(working copy)
@@ -16526,6 +16526,8 @@  rtl_for_decl_init (tree init, tree type)
 {
   rtx rtl = NULL_RTX;
 
+  STRIP_NOPS (init);
+
   /* If a variable is initialized with a string constant without embedded
      zeros, build CONST_STRING.  */
   if (TREE_CODE (init) == STRING_CST && TREE_CODE (type) == ARRAY_TYPE)
@@ -16550,7 +16552,10 @@  rtl_for_decl_init (tree init, tree type)
     }
   /* Other aggregates, and complex values, could be represented using
      CONCAT: FIXME!  */
-  else if (AGGREGATE_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)
+  else if (AGGREGATE_TYPE_P (type)
+	   || (TREE_CODE (init) == VIEW_CONVERT_EXPR
+	       && AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (init, 0))))
+	   || TREE_CODE (type) == COMPLEX_TYPE)
     ;
   /* Vectors only work if their mode is supported by the target.
      FIXME: generic vectors ought to work too.  */