]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Do not get the expression of a dispatch table that is...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 12 Jun 2018 10:20:02 +0000 (10:20 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 12 Jun 2018 10:20:02 +0000 (10:20 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Do not get
the expression of a dispatch table that is not being defined.
<E_Record_Subtype>: Remove obsolete kludge.

From-SVN: r261485

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index aed04eabb957fdda4cb9efffe9671323a7c1a312..1356015fd6f3f3d8cc86c0dd135f663ba6574a40 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Do not get
+       the expression of a dispatch table that is not being defined.
+       <E_Record_Subtype>: Remove obsolete kludge.
+
 2018-06-12  Eric Botcazou  <ebotcazou@adacore.com>
 
        Backpor from mainline
index df27f209fb1bddf772fefc2f6146034292f86106..52860a35f4376017dd3cbac0494ddf4ca30a3bdb 100644 (file)
@@ -592,13 +592,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
       /* If we have a constant that we are not defining, get the expression it
         was defined to represent.  This is necessary to avoid generating dumb
         elaboration code in simple cases, but we may throw it away later if it
-        is not a constant.  But do not retrieve it if it is an allocator since
+        is not a constant.  But do not do it for dispatch tables because they
+        are only referenced indirectly and we need to have a consistent view
+        of the exported and of the imported declarations of the tables from
+        external units for them to be properly merged in LTO mode.  Moreover
+        simply do not retrieve the expression it if it is an allocator since
         the designated type might still be dummy at this point.  Note that we
         invoke gnat_to_gnu_external and not gnat_to_gnu because the expression
         may contain N_Expression_With_Actions nodes and thus declarations of
         objects from other units that we need to discard.  */
       if (!definition
          && !No_Initialization (Declaration_Node (gnat_entity))
+         && !Is_Dispatch_Table_Entity (gnat_entity)
          && Present (gnat_temp = Expression (Declaration_Node (gnat_entity)))
          && Nkind (gnat_temp) != N_Allocator
          && (!type_annotate_only || Compile_Time_Known_Value (gnat_temp)))
@@ -3404,20 +3409,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
              break;
            }
 
-         /* If this is a record subtype associated with a dispatch table,
-            strip the suffix.  This is necessary to make sure 2 different
-            subtypes associated with the imported and exported views of a
-            dispatch table are properly merged in LTO mode.  */
-         if (Is_Dispatch_Table_Entity (gnat_entity))
-           {
-             char *p;
-             Get_Encoded_Name (gnat_entity);
-             p = strchr (Name_Buffer, '_');
-             gcc_assert (p);
-             strcpy (p+2, "dtS");
-             gnu_entity_name = get_identifier (Name_Buffer);
-           }
-
          /* When the subtype has discriminants and these discriminants affect
             the initial shape it has inherited, factor them in.  But for an
             Unchecked_Union (it must be an Itype), just return the type.