]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Standard types are not artificial
authorTom Tromey <tromey@adacore.com>
Wed, 10 Jul 2024 17:29:11 +0000 (11:29 -0600)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 25 Oct 2024 09:09:03 +0000 (11:09 +0200)
This changes gigi so that standard types are no longer marked
artificial.  This change is needed to prevent subsequent patches from
causing standard types to have their names elided.  Also, although
DWARF says that DW_AT_artificial is used for "the declaration of an
object or type artificially generated by a compiler and not explicitly
declared by the source program", it seems to me that types provided by
the language should not be marked as such; and this is what the C and
C++ compilers do.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (is_artificial): New function.
(gnat_to_gnu_entity): Use it.

gcc/ada/gcc-interface/decl.cc

index f22dea0d2cfe0e996bd6e6eaded7cf4476693f3c..aa22c495a1697df3c7361d5e9589515b4e2914bd 100644 (file)
@@ -259,6 +259,18 @@ typedef struct {
 
 static bool intrin_profiles_compatible_p (const intrin_binding_t *);
 
+/* Return true if GNAT_ENTITY is artificial, false otherwise.  */
+
+static bool
+is_artificial (Entity_Id gnat_entity)
+{
+  if (Comes_From_Source (gnat_entity))
+    return false;
+  if (Sloc (gnat_entity) == Standard_Location)
+    return false;
+  return true;
+}
+
 /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada
    entity, return the equivalent GCC tree for that entity (a ..._DECL node)
    and associate the ..._DECL node with the input GNAT defining identifier.
@@ -284,7 +296,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
   /* True if this is a type.  */
   const bool is_type = IN (kind, Type_Kind);
   /* True if this is an artificial entity.  */
-  const bool artificial_p = !Comes_From_Source (gnat_entity);
+  const bool artificial_p = is_artificial (gnat_entity);
   /* True if debug info is requested for this entity.  */
   const bool debug_info_p = Needs_Debug_Info (gnat_entity);
   /* True if this entity is to be considered as imported.  */
@@ -3006,7 +3018,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
                 in order to decode the packed array type.  */
              tree gnu_tmp_decl
                = create_type_decl (gnu_entity_name, gnu_type,
-                                   !Comes_From_Source (Etype (gnat_entity))
+                                   is_artificial (Etype (gnat_entity))
                                    && artificial_p, debug_info_p,
                                    gnat_entity);
              /* Save it as our equivalent in case the call below elaborates