diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-01-29 15:33:47 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-01-29 15:33:47 +0100 |
commit | 7e8561128dd304306cdf703d76c6cf59a7e753e7 (patch) | |
tree | decd418f191225b68d8e6f42529425183bc85eee /gcc/ada | |
parent | 4e3da85af1403ed3599404bd154c1afc0d3e4b13 (diff) | |
download | gcc-7e8561128dd304306cdf703d76c6cf59a7e753e7.zip gcc-7e8561128dd304306cdf703d76c6cf59a7e753e7.tar.gz gcc-7e8561128dd304306cdf703d76c6cf59a7e753e7.tar.bz2 |
[multiple changes]
2013-01-29 Ed Schonberg <schonberg@adacore.com>
* 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 <celier@adacore.com>
* prj-proc.adb: Minor comment spelling fix.
From-SVN: r195546
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/ada/exp_ch5.adb | 51 | ||||
-rw-r--r-- | gcc/ada/prj-proc.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 7 |
4 files changed, 55 insertions, 19 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1680a52..73ddbfb 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2013-01-29 Ed Schonberg <schonberg@adacore.com> + + * 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 <celier@adacore.com> + + * prj-proc.adb: Minor comment spelling fix. + 2013-01-29 Pascal Obry <obry@adacore.com> * prj-proc.adb (Process_Expression_Variable_Decl): Prepend diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 66aeb68..2bdb827 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 5e2828b..39ebe70 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 0fc2365..336ce67 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; |