diff mbox

[Ada] fix gnat_write_global_declarations glitch in LTO mode

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

Commit Message

Eric Botcazou May 20, 2012, 9:36 a.m. UTC
The routine uses an anonymous static variable and this breaks in LTO mode 
because a DECL_NAME is expected.

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


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

	* gcc-interface/utils.c (gnat_write_global_declarations): Put a name
	on the dummy global variable.


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

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

Patch

Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c	(revision 187691)
+++ gcc-interface/utils.c	(working copy)
@@ -5586,8 +5586,12 @@  gnat_write_global_declarations (void)
   if (!VEC_empty (tree, types_used_by_cur_var_decl))
     {
       struct varpool_node *node;
+      char *label;
+
+      ASM_FORMAT_PRIVATE_NAME (label, first_global_object_name, 0);
       dummy_global
-	= build_decl (BUILTINS_LOCATION, VAR_DECL, NULL_TREE, void_type_node);
+	= build_decl (BUILTINS_LOCATION, VAR_DECL, get_identifier (label),
+		      void_type_node);
       TREE_STATIC (dummy_global) = 1;
       TREE_ASM_WRITTEN (dummy_global) = 1;
       node = varpool_node (dummy_global);