Fix assembler name collision
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Dec 2020 09:40:23 +0000 (10:40 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Dec 2020 09:40:23 +0000 (10:40 +0100)
Gigi uses a dummy global variable to register global types for debug
info purposes and its name can now collide with user variables.

gcc/ada/ChangeLog:
* gcc-interface/trans.c (lvalue_for_aggregate_p): Also return true
for return statements.
* gcc-interface/utils.c (gnat_write_global_declarations): Use the
maximum index for the dummy object to avoid a name collision.

gcc/ada/gcc-interface/trans.c
gcc/ada/gcc-interface/utils.c

index 07e5a285b2b0ead1cbcc4bba354707cdfcc1b691..bf8289ba32364f92d8b36e8ee3b2914aa275c268 100644 (file)
@@ -970,6 +970,10 @@ lvalue_for_aggregate_p (Node_Id gnat_node, tree gnu_type)
       /* Even if the parameter is by copy, prefer an lvalue.  */
       return true;
 
+    case N_Simple_Return_Statement:
+      /* Likewise for a return value.  */
+      return true;
+
     case N_Indexed_Component:
     case N_Selected_Component:
       /* If an elementary component is used, take it from the constant.  */
index 1d49db9fb1b56fc12eae74fa6ffde80253644df8..494f60e0879325b457285c8f55085c29041e7fb8 100644 (file)
@@ -5903,7 +5903,7 @@ gnat_write_global_declarations (void)
       struct varpool_node *node;
       char *label;
 
-      ASM_FORMAT_PRIVATE_NAME (label, first_global_object_name, 0);
+      ASM_FORMAT_PRIVATE_NAME (label, first_global_object_name, ULONG_MAX);
       dummy_global
        = build_decl (BUILTINS_LOCATION, VAR_DECL, get_identifier (label),
                      void_type_node);