https://gcc.gnu.org/g:b857742bc8b675073b5c2ab7687ce09a42789ead

commit r15-4655-gb857742bc8b675073b5c2ab7687ce09a42789ead
Author: Tom Tromey <tro...@adacore.com>
Date:   Wed Jul 10 11:46:57 2024 -0600

    ada: Add 'artificial_p' parameter to build_unc_object_type
    
    This adds an 'artificial_p' parameter to build_unc_object_type, so
    that the artificiality of the type can be propagated to
    create_type_decl.  This will affect the namelessness of the type in a
    subsequent patch.
    
    gcc/ada/ChangeLog:
    
            * gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to
            build_unc_object_type.
            * gcc-interface/gigi.h (build_unc_object_type): Update.
            * gcc-interface/utils.cc (build_unc_object_type) Add artificial_p
            parameter.
            (build_unc_object_type_from_ptr): Update.

Diff:
---
 gcc/ada/gcc-interface/decl.cc  |  2 +-
 gcc/ada/gcc-interface/gigi.h   |  9 ++++++---
 gcc/ada/gcc-interface/utils.cc | 13 ++++++++-----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index aa22c495a169..14b39b336bd8 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2496,7 +2496,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
            ? create_concat_name (gnat_name, "XUT")
            : gnu_entity_name;
        obj = build_unc_object_type (gnu_template_type, tem, xut_name,
-                                    debug_info_p);
+                                    artificial_p, debug_info_p);
 
        SET_TYPE_UNCONSTRAINED_ARRAY (obj, gnu_type);
        TYPE_OBJECT_RECORD_TYPE (gnu_type) = obj;
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index f4b302be3e0b..00f00d967c73 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -742,10 +742,13 @@ extern tree build_template (tree template_type, tree 
array_type, tree expr);
    is an unconstrained array.  This consists of a RECORD_TYPE containing a
    field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an ARRAY_TYPE.
    If ARRAY_TYPE is that of an unconstrained array, this is used to represent
-   an arbitrary unconstrained object.  Use NAME as the name of the record.
-   DEBUG_INFO_P is true if we need to write debug information for the type.  */
+   an arbitrary unconstrained object.  Use NAME as the name of the
+   record.  ARTIFICIAL_P is true if the type was generated by the
+   compiler, or false if the type came from source.  DEBUG_INFO_P is
+   true if we need to write debug information for the type.  */
 extern tree build_unc_object_type (tree template_type, tree object_type,
-                                  tree name, bool debug_info_p);
+                                  tree name, bool artificial_p,
+                                  bool debug_info_p);
 
 /* Same as build_unc_object_type, but taking a thin or fat pointer type
    instead of the template type.  */
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 951d3848d09b..9e2715a8d81f 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -4465,12 +4465,14 @@ build_vector_type_for_array (tree array_type, tree 
attribute)
    is an unconstrained array.  This consists of a RECORD_TYPE containing a
    field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an ARRAY_TYPE.
    If ARRAY_TYPE is that of an unconstrained array, this is used to represent
-   an arbitrary unconstrained object.  Use NAME as the name of the record.
-   DEBUG_INFO_P is true if we need to write debug information for the type.  */
+   an arbitrary unconstrained object.  Use NAME as the name of the
+   record.  ARTIFICIAL_P is true if the type was generated by the
+   compiler, or false if the type came from source.  DEBUG_INFO_P is
+   true if we need to write debug information for the type.  */
 
 tree
 build_unc_object_type (tree template_type, tree object_type, tree name,
-                      bool debug_info_p)
+                      bool artificial_p, bool debug_info_p)
 {
   tree type = make_node (RECORD_TYPE);
   tree template_field
@@ -4487,7 +4489,7 @@ build_unc_object_type (tree template_type, tree 
object_type, tree name,
 
   /* Declare it now since it will never be declared otherwise.  This is
      necessary to ensure that its subtrees are properly marked.  */
-  create_type_decl (name, type, true, debug_info_p, Empty);
+  create_type_decl (name, type, artificial_p, debug_info_p, Empty);
 
   return type;
 }
@@ -4508,7 +4510,8 @@ build_unc_object_type_from_ptr (tree thin_fat_ptr_type, 
tree object_type,
        : TREE_TYPE (TYPE_FIELDS (TREE_TYPE (thin_fat_ptr_type))));
 
   return
-    build_unc_object_type (template_type, object_type, name, debug_info_p);
+    build_unc_object_type (template_type, object_type, name, true,
+                          debug_info_p);
 }
 
 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE.

Reply via email to