diff options
author | Tom Tromey <tromey@adacore.com> | 2024-07-09 09:36:26 -0600 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-10-25 11:09:04 +0200 |
commit | a60e7289350d7b04d4c81187070d705f441e9c70 (patch) | |
tree | eca411c8f1730be6e26290480a9205c909311c94 /gcc/ada/gcc-interface | |
parent | 88715b94809895343caa405accb8f3c42c791853 (diff) | |
download | gcc-a60e7289350d7b04d4c81187070d705f441e9c70.zip gcc-a60e7289350d7b04d4c81187070d705f441e9c70.tar.gz gcc-a60e7289350d7b04d4c81187070d705f441e9c70.tar.bz2 |
ada: Set DECL_NAMELESS in create_type_decl
When using minimal encodings, most artificial types do not need to
have their names emitted in the DWARF. This patch changes the
compiler to generally omit these names.
However, a subset of names are needed: when the compiler creates an
artificial type for certain kinds of arrays, the name is needed by
gdb. So, a new parameter is added to create_type_decl to allow this
omission to be disabled.
Note that simply passing 'false' as the artificial_p argument to
create_type_decl doesn't work properly -- other parts of the compiler
seem to rely on this flag being set, and so making this change causes
ICEs.
gcc/ada/ChangeLog:
* gcc-interface/decl.cc (gnat_to_gnu_entity): Update some calls to
create_type_decl.
* gcc-interface/gigi.h (create_type_decl): Add can_be_nameless parameter.
* gcc-interface/utils.cc (create_type_decl): Add can_be_nameless
parameter. Set DECL_NAMELESS on type decl.
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/decl.cc | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/gigi.h | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.cc | 9 |
3 files changed, 15 insertions, 7 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index ba75fa3..372d72a 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -2003,7 +2003,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Create a stripped-down declaration, mainly for debugging. */ t = create_type_decl (gnu_entity_name, gnu_type, true, debug_info_p, - gnat_entity); + gnat_entity, false); /* Now save it and build the enclosing record type. */ gnu_field_type = gnu_type; @@ -2276,7 +2276,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ? create_concat_name (gnat_name, "XUP") : gnu_entity_name; create_type_decl (xup_name, gnu_fat_type, true, debug_info_p, - gnat_entity); + gnat_entity, false); /* Build a reference to the template from a PLACEHOLDER_EXPR that is the fat pointer. This will be used to access the individual @@ -3022,7 +3022,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) = create_type_decl (gnu_entity_name, gnu_type, is_artificial (Etype (gnat_entity)) && artificial_p, debug_info_p, - gnat_entity); + gnat_entity, false); /* Save it as our equivalent in case the call below elaborates this type again. */ save_gnu_tree (gnat_entity, gnu_tmp_decl, false); diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 00f00d9..875a3d6 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -625,9 +625,12 @@ extern tree create_type_stub_decl (tree name, tree type); used in the declaration. ARTIFICIAL_P is true if the declaration was generated by the compiler. DEBUG_INFO_P is true if we need to write debug information about this type. GNAT_NODE is used for the position - of the decl. */ + of the decl. Normally, an artificial type might be marked as + nameless. However, if CAN_BE_NAMELESS is false, this marking is + disabled and the name will always be attached for the type. */ extern tree create_type_decl (tree name, tree type, bool artificial_p, - bool debug_info_p, Node_Id gnat_node); + bool debug_info_p, Node_Id gnat_node, + bool can_be_nameless = true); /* Return a VAR_DECL or CONST_DECL node. diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index a06366b..3a571e0 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -2846,11 +2846,13 @@ create_type_stub_decl (tree name, tree type) used in the declaration. ARTIFICIAL_P is true if the declaration was generated by the compiler. DEBUG_INFO_P is true if we need to write debug information about this type. GNAT_NODE is used for the position - of the decl. */ + of the decl. Normally, an artificial type might be marked as + nameless. However, if CAN_BE_NAMELESS is false, this marking is + disabled and the name will always be attached for the type. */ tree create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p, - Node_Id gnat_node) + Node_Id gnat_node, bool can_be_nameless) { enum tree_code code = TREE_CODE (type); bool is_named @@ -2872,6 +2874,9 @@ create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p, DECL_ARTIFICIAL (type_decl) = artificial_p; TYPE_ARTIFICIAL (type) = artificial_p; + DECL_NAMELESS (type_decl) = (artificial_p + && can_be_nameless + && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL); /* Add this decl to the current binding level. */ gnat_pushdecl (type_decl, gnat_node); |