From 67e71f41612825aefa16dd1a2fd3be6587cb2957 Mon Sep 17 00:00:00 2001 From: charlet Date: Tue, 29 Jan 2013 14:33:47 +0000 Subject: 2013-01-29 Ed Schonberg * exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Preserve loop identifier only if it comes from source. (Expand_N_Loop_Statement): If the domain of iteration is an enumeration type with a representation clause, remove from visibility the loop identifier before rewriting the loop as a block with a declaration for said identifier. * sem_util.adb (Remove_Homonym): Handle properly the default case. 2013-01-29 Vincent Celier * prj-proc.adb: Minor comment spelling fix. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195546 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 14 ++++++++++++++ gcc/ada/exp_ch5.adb | 51 ++++++++++++++++++++++++++++++++++----------------- gcc/ada/prj-proc.adb | 2 +- gcc/ada/sem_util.adb | 7 ++++++- 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1680a5286ec..73ddbfb5711 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2013-01-29 Ed Schonberg + + * exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Preserve loop + identifier only if it comes from source. + (Expand_N_Loop_Statement): If the domain of iteration is an + enumeration type with a representation clause, remove from + visibility the loop identifier before rewriting the loop as a + block with a declaration for said identifier. + * sem_util.adb (Remove_Homonym): Handle properly the default case. + +2013-01-29 Vincent Celier + + * prj-proc.adb: Minor comment spelling fix. + 2013-01-29 Pascal Obry * prj-proc.adb (Process_Expression_Variable_Decl): Prepend diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 66aeb681dac..2bdb82797ab 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -3743,10 +3743,14 @@ package body Exp_Ch5 is end loop; end if; - -- If original loop has a name, preserve it so it can be recognized by - -- an exit statement in the body of the rewritten loop. + -- If original loop has a source name, preserve it so it can be + -- recognized by an exit statement in the body of the rewritten loop. + -- This only concerns source names: the generated name of an anonymous + -- loop will be create again during the subsequent analysis below. - if Present (Identifier (N)) then + if Present (Identifier (N)) + and then Comes_From_Source (Identifier (N)) + then Set_Identifier (Core_Loop, Relocate_Node (Identifier (N))); end if; @@ -3810,6 +3814,7 @@ package body Exp_Ch5 is Ltype : constant Entity_Id := Etype (Loop_Id); Btype : constant Entity_Id := Base_Type (Ltype); Expr : Node_Id; + Decls : List_Id; New_Id : Entity_Id; begin @@ -3869,6 +3874,16 @@ package body Exp_Ch5 is New_List (New_Reference_To (New_Id, Loc))); end if; + -- Build declaration for loop identifier + + Decls := + New_List ( + Make_Object_Declaration (Loc, + Defining_Identifier => Loop_Id, + Constant_Present => True, + Object_Definition => New_Reference_To (Ltype, Loc), + Expression => Expr)); + Rewrite (N, Make_Loop_Statement (Loc, Identifier => Identifier (N), @@ -3916,14 +3931,7 @@ package body Exp_Ch5 is Statements => New_List ( Make_Block_Statement (Loc, - Declarations => New_List ( - Make_Object_Declaration (Loc, - Defining_Identifier => Loop_Id, - Constant_Present => True, - Object_Definition => - New_Reference_To (Ltype, Loc), - Expression => Expr)), - + Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Statements (N)))), @@ -3931,13 +3939,22 @@ package body Exp_Ch5 is End_Label => End_Label (N))); -- The loop parameter's entity must be removed from the loop - -- scope's entity list, since it will now be located in the - -- new block scope. Any other entities already associated with - -- the loop scope, such as the loop parameter's subtype, will - -- remain there. + -- scope's entity list and rendered invisible, since it will + -- now be located in the new block scope. Any other entities + -- already associated with the loop scope, such as the loop + -- parameter's subtype, will remain there. + + -- In an element loop, the loop will contain a declaration for + -- a cursor variable; otherwise the loop id is the first entity + -- in the scope constructed for the loop. + + if Comes_From_Source (Loop_Id) then + pragma Assert (First_Entity (Scope (Loop_Id)) = Loop_Id); + null; + end if; - pragma Assert (First_Entity (Scope (Loop_Id)) = Loop_Id); Set_First_Entity (Scope (Loop_Id), Next_Entity (Loop_Id)); + Remove_Homonym (Loop_Id); if Last_Entity (Scope (Loop_Id)) = Loop_Id then Set_Last_Entity (Scope (Loop_Id), Empty); diff --git a/gcc/ada/prj-proc.adb b/gcc/ada/prj-proc.adb index 5e2828be5d8..39ebe70b4ad 100644 --- a/gcc/ada/prj-proc.adb +++ b/gcc/ada/prj-proc.adb @@ -2076,7 +2076,7 @@ package body Prj.Proc is Val := Shared.String_Elements.Table (Val).Next; end loop; - -- Prepend them in the oder found in the attribute + -- Prepend them in the order found in the attribute for K in Positive range 1 .. Positive (List.Length) loop Prj.Env.Add_Directories diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0fc23655900..336ce67c49a 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -12638,6 +12638,7 @@ package body Sem_Util is else Set_Name_Entity_Id (Chars (E), Empty); end if; + else H := Current_Entity (E); while Present (H) and then H /= E loop @@ -12645,7 +12646,11 @@ package body Sem_Util is H := Homonym (H); end loop; - Set_Homonym (Prev, Homonym (E)); + -- If E is not on the homonym chain, nothing to do + + if Present (H) then + Set_Homonym (Prev, Homonym (E)); + end if; end if; end Remove_Homonym; -- cgit v1.2.1