diff mbox

[Ada] Small tweak to gigi

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

Commit Message

Eric Botcazou Dec. 11, 2011, 9:42 a.m. UTC
This moves the initialization of the linemap up to before the first assertion 
at the beginning of the gigi routine.  As experienced under PR ada/49084, if 
the assertion fails and the linemap isn't initialized yet, things can go awry.

Tested on i586-suse-linux, applied on the mainline.


2011-12-11  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (gigi): Initialize the linemap earlier.
diff mbox

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 182102)
+++ gcc-interface/trans.c	(working copy)
@@ -297,13 +297,6 @@  gigi (Node_Id gnat_root, int max_gnat_no
 
   type_annotate_only = (gigi_operating_mode == 1);
 
-  gcc_assert (Nkind (gnat_root) == N_Compilation_Unit);
-
-  /* Declare the name of the compilation unit as the first global
-     name in order to make the middle-end fully deterministic.  */
-  t = create_concat_name (Defining_Entity (Unit (gnat_root)), NULL);
-  first_global_object_name = ggc_strdup (IDENTIFIER_POINTER (t));
-
   for (i = 0; i < number_file; i++)
     {
       /* Use the identifier table to make a permanent copy of the filename as
@@ -328,6 +321,13 @@  gigi (Node_Id gnat_root, int max_gnat_no
       linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
     }
 
+  gcc_assert (Nkind (gnat_root) == N_Compilation_Unit);
+
+  /* Declare the name of the compilation unit as the first global
+     name in order to make the middle-end fully deterministic.  */
+  t = create_concat_name (Defining_Entity (Unit (gnat_root)), NULL);
+  first_global_object_name = ggc_strdup (IDENTIFIER_POINTER (t));
+
   /* Initialize ourselves.  */
   init_code_table ();
   init_gnat_to_gnu ();