When the declaration of the loop entity of an Ada-2012-style array iterator
is rewritten as a renaming of the indexed array, debug info was not being
generated for the renaming, preventing display of the entity (gdb generates
a "no definition in current context" message).  The loop entity of such a
renaming is now marked as needing debug info.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-30  Gary Dismukes  <dismu...@adacore.com>

        * exp_ch5.adb (Expand_Iterator_Loop_Over_Array): For the case of a
        loop entity which is rewritten as a renaming
        of the indexed array, explicitly mark the entity as needing
        debug info so that Materialize entity will be set later by
        Debug_Renaming_Declaration when the renaming is expanded.

Index: exp_ch5.adb
===================================================================
--- exp_ch5.adb (revision 185995)
+++ exp_ch5.adb (working copy)
@@ -3303,6 +3303,14 @@
                New_Reference_To (Component_Type (Array_Typ), Loc),
              Name                => Ind_Comp));
 
+         --  Mark the loop variable as needing debug info, so that expansion
+         --  of the renaming will result in Materialize_Entity getting set via
+         --  Debug_Renaming_Declaration. (This setting is needed here because
+         --  the setting in Freeze_Entity comes after the expansion, which is
+         --  too late. ???)
+
+         Set_Debug_Info_Needed (Id);
+
       --  for Index in Array loop
 
       --  This case utilizes the already given iterator name

Reply via email to