diff mbox

[Ada] Fix ICE on constant with record type in LTO mode

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

Commit Message

Eric Botcazou May 18, 2012, 8:23 p.m. UTC
The compiler aborts on the testcase in LTO mode because of a record type with a 
size expression containing a CALL_EXPR at the global level.  The simple fix is 
to elaborate the size expression like in all the other cases.

Tested on i586-suse-linux, applied on the mainline and 4.7 branch.


2012-05-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: For an object at
	global level with unconstrained nominal subtype and a non-fixed size,
	make a variable for the size.


2012-05-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/lto12.ads: New test.
	* gnat.dg/specs/lto12_pkg.ads: New helper.
diff mbox

Patch

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 187654)
+++ gcc-interface/decl.c	(working copy)
@@ -760,6 +760,14 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 		gnu_size = max_size (TYPE_SIZE (gnu_type), true);
 		mutable_p = true;
 	      }
+
+	    /* If we are at global level and the size isn't constant, call
+	       elaborate_expression_1 to make a variable for it rather than
+	       calculating it each time.  */
+	    if (global_bindings_p () && !TREE_CONSTANT (gnu_size))
+	      gnu_size = elaborate_expression_1 (gnu_size, gnat_entity,
+						 get_identifier ("SIZE"),
+						 definition, false);
 	  }
 
 	/* If the size is zero byte, make it one byte since some linkers have