aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-11-12 11:55:37 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2015-11-12 11:55:37 +0100
commit1d4b96e007641088199133bb37a13338eb4fb2ff (patch)
tree34ae13ea914b1a19196c1f49ae686f6b549cc8aa /gcc/ada/gcc-interface/decl.c
parent81501d2b45d990aaab9c0c3b85a13b4315ed567e (diff)
downloadgcc-1d4b96e007641088199133bb37a13338eb4fb2ff.zip
gcc-1d4b96e007641088199133bb37a13338eb4fb2ff.tar.gz
gcc-1d4b96e007641088199133bb37a13338eb4fb2ff.tar.bz2
decl.c (gnat_to_gnu_entity): Create IMPORTED_DECL nodes to describe the subprogram renamings which are...
2015-11-12 Pierre-Marie de Rodat <derodat@adacore.com> * gcc-interface/decl.c (gnat_to_gnu_entity): Create IMPORTED_DECL nodes to describe the subprogram renamings which are relevant at debug time. * gcc-interface/gigi.h (get_debug_scope): Add declaration. * gcc-interface/trans.c (Identifier_to_gnu): Consider N_Defining_Operator_Symbol as valid entities. (gnat_to_gnu): Handle N_Defining_Operator_Symbol the same way as other entities. Introduce a specific handling for N_Subprogram_Renaming_Declaration: call gnat_to_gnu_entity on the entity defined for relevant ones. (process_decls): Process subprogram renaming declarations during the second pass only. * gcc-interface/utils.c (get_debug_scope): Make it external. Consider N_Defining_Operator_Symbol as valid entities. (gnat_write_global_declarations): Output debugging information for top-level imported declarations. * gcc-interface/Makefile.in: Fix typo. From-SVN: r230227
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index b345a88..59754b6 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -4131,6 +4131,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
of its type, so we must elaborate that type now. */
if (Present (Alias (gnat_entity)))
{
+ const Entity_Id gnat_renamed = Renamed_Object (gnat_entity);
+
if (Ekind (Alias (gnat_entity)) == E_Enumeration_Literal)
gnat_to_gnu_entity (Etype (Alias (gnat_entity)), NULL_TREE, 0);
@@ -4143,6 +4145,33 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
if (Is_Itype (Etype (gnat_temp)))
gnat_to_gnu_entity (Etype (gnat_temp), NULL_TREE, 0);
+ /* Materialize renamed subprograms in the debugging information
+ when the renamed object is compile time known. We can consider
+ such renamings as imported declarations.
+
+ Because the parameters in generics instantiation are generally
+ materialized as renamings, we ofter end up having both the
+ renamed subprogram and the renaming in the same context and with
+ the same name: in this case, renaming is both useless debug-wise
+ and potentially harmful as name resolution in the debugger could
+ return twice the same entity! So avoid this case. */
+ if (debug_info_p && !artificial_p
+ && !(get_debug_scope (gnat_entity, NULL)
+ == get_debug_scope (gnat_renamed, NULL)
+ && Name_Equals (Chars (gnat_entity),
+ Chars (gnat_renamed)))
+ && Present (gnat_renamed)
+ && (Ekind (gnat_renamed) == E_Function
+ || Ekind (gnat_renamed) == E_Procedure)
+ && gnu_decl != NULL_TREE
+ && TREE_CODE (gnu_decl) == FUNCTION_DECL)
+ {
+ tree decl = build_decl (input_location, IMPORTED_DECL,
+ gnu_entity_name, void_type_node);
+ IMPORTED_DECL_ASSOCIATED_DECL (decl) = gnu_decl;
+ gnat_pushdecl (decl, gnat_entity);
+ }
+
break;
}