diff options
author | Javier Miranda <miranda@adacore.com> | 2025-02-06 09:40:57 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2025-06-05 10:18:38 +0200 |
commit | 5ece6a808254ca1653872cc2ca64a72e91d19731 (patch) | |
tree | 7d6e88e2d1bd247bce2d83bc3eb5fb9601788683 | |
parent | cf1f3f7c34292a11ee831b61d44b5cbab280e272 (diff) | |
download | gcc-5ece6a808254ca1653872cc2ca64a72e91d19731.zip gcc-5ece6a808254ca1653872cc2ca64a72e91d19731.tar.gz gcc-5ece6a808254ca1653872cc2ca64a72e91d19731.tar.bz2 |
ada: Spurious compilation error with repeated loop index
When multiple for-loop statements in the same scope use the
same index name to iterate through container elements, the
compiler reports a spurious error indicating a conflict
between index names.
gcc/ada/ChangeLog:
* exp_ch7.adb (Process_Object_Declaration): Avoid generating
duplicate names for master nodes.
-rw-r--r-- | gcc/ada/exp_ch7.adb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 67af1d7..905094c 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -2783,16 +2783,31 @@ package body Exp_Ch7 is Master_Node_Id := Make_Defining_Identifier (Master_Node_Loc, Chars => New_External_Name (Chars (Obj_Id), Suffix => "MN")); + Master_Node_Decl := Make_Master_Node_Declaration (Master_Node_Loc, Master_Node_Id, Obj_Id); Push_Scope (Scope (Obj_Id)); + + -- Avoid generating duplicate names for master nodes + + if Ekind (Obj_Id) = E_Loop_Parameter + and then + Present (Current_Entity_In_Scope (Chars (Master_Node_Id))) + then + Set_Chars (Master_Node_Id, + New_External_Name (Chars (Obj_Id), + Suffix => "MN", + Suffix_Index => -1)); + end if; + if not Has_Strict_Ctrl_Objs or else Count = 1 then Prepend_To (Decls, Master_Node_Decl); else Insert_Before (Decl, Master_Node_Decl); end if; + Analyze (Master_Node_Decl); Pop_Scope; |