From e8fa3dcdd50c6c532d9dab2da73b3dd23f5c27cb Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Wed, 30 Jul 2014 14:52:44 +0200 Subject: decl.c (gnat_to_gnu_entity): Create a mere scalar constant instead of a reference for a renaming of scalar... 2014-07-30 Pierre-Marie Derodat * gcc-interface/decl.c (gnat_to_gnu_entity) : Create a mere scalar constant instead of a reference for a renaming of scalar literal. * gcc-interface/utils.c (renaming_from_generic_instantiation_p): New. * gcc-interface/gigi.h (renaming_from_generic_instantiation_p): New. From-SVN: r213258 --- gcc/ada/gcc-interface/utils.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'gcc/ada/gcc-interface/utils.c') diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 2c15c98..a9afc53 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -580,7 +580,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) TREE_NO_WARNING (decl) = (No (gnat_node) || Warnings_Off (gnat_node)); /* Set the location of DECL and emit a declaration for it. */ - if (Present (gnat_node)) + if (Present (gnat_node) && !renaming_from_generic_instantiation_p (gnat_node)) Sloc_to_locus (Sloc (gnat_node), &DECL_SOURCE_LOCATION (decl)); add_decl_expr (decl, gnat_node); @@ -2550,6 +2550,37 @@ value_factor_p (tree value, HOST_WIDE_INT factor) return false; } +/* Return whether GNAT_NODE is a defining identifier for a renaming that comes + from the parameter association for the instantiation of a generic. We do + not want to emit source location for them: the code generated for their + initialization is likely to disturb debugging. */ + +bool +renaming_from_generic_instantiation_p (Node_Id gnat_node) +{ + if (Nkind (gnat_node) != N_Defining_Identifier + || !IN (Ekind (gnat_node), Object_Kind) + || Comes_From_Source (gnat_node) + || !Present (Renamed_Object (gnat_node))) + return false; + + /* Get the object declaration of the renamed object, if any and if the + renamed object is a mere identifier. */ + gnat_node = Renamed_Object (gnat_node); + if (Nkind (gnat_node) != N_Identifier) + return false; + + gnat_node = Entity (gnat_node); + if (!Present (Parent (gnat_node))) + return false; + + gnat_node = Parent (gnat_node); + return + (Present (gnat_node) + && Nkind (gnat_node) == N_Object_Declaration + && Present (Corresponding_Generic_Association (gnat_node))); +} + /* Return VALUE scaled by the biggest power-of-2 factor of EXPR. */ static unsigned int -- cgit v1.1