From 75c907757cbfa48b37eaee5fde2769eae2fd204d Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 2 Aug 2011 15:12:40 +0200 Subject: [PATCH] [multiple changes] 2011-08-02 Ed Schonberg * sem_ch5.adb (Analyze_Iteration_Scheme): For an Ada2012 iterator with "of", pre-analyze expression in case it is a function call with finalization actions that must be placed ahead of the loop. * exp_ch5.adb (Expand_Iterator_Loop): If condition_actions are present on an Ada2012 iterator, insert them ahead of the rewritten loop. 2011-08-02 Geert Bosch * cstand.adb (Create_Float_Types): Only consider C's long double for Long_Long_Float, in addition to double. From-SVN: r177146 --- gcc/ada/ChangeLog | 13 +++++++++++++ gcc/ada/cstand.adb | 24 ++++-------------------- gcc/ada/exp_ch5.adb | 10 ++++++++++ gcc/ada/sem_ch5.adb | 12 ++++++++---- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 83ff0830e2e..9b6d9734b86 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2011-08-02 Ed Schonberg + + * sem_ch5.adb (Analyze_Iteration_Scheme): For an Ada2012 iterator with + "of", pre-analyze expression in case it is a function call with + finalization actions that must be placed ahead of the loop. + * exp_ch5.adb (Expand_Iterator_Loop): If condition_actions are present + on an Ada2012 iterator, insert them ahead of the rewritten loop. + +2011-08-02 Geert Bosch + + * cstand.adb (Create_Float_Types): Only consider C's long double for + Long_Long_Float, in addition to double. + 2011-08-02 Robert Dewar * sem_ch3.adb, sem_ch5.adb, sem_type.adb, switch-c.adb, switch-c.ads, diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index 2df2a407574..26d501764bf 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -466,29 +466,13 @@ package body CStand is declare Max_HW_Digs : constant := 18; - LF_Digs : constant Pos := - UI_To_Int (Digits_Value (Standard_Long_Float)); + -- Maximum hardware digits supported + LLF : Entity_Id := Find_Back_End_Float_Type ("long double"); - E : Elmt_Id := First_Elmt (Back_End_Float_Types); - N : Node_Id; + -- Entity for long double type begin - if Present (LLF) and then Digits_Value (LLF) > Max_HW_Digs then - LLF := Empty; - end if; - - while No (LLF) and then Present (E) loop - N := Node (E); - if UI_To_Int (Digits_Value (N)) in LF_Digs + 1 .. Max_HW_Digs - and then Machine_Radix_Value (N) = Uint_2 - then - LLF := N; - end if; - - Next_Elmt (E); - end loop; - - if No (LLF) then + if No (LLF) or else Digits_Value (LLF) > Max_HW_Digs then LLF := Standard_Long_Float; end if; diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index bd85af264c9..f102cf9eafc 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2952,6 +2952,15 @@ package body Exp_Ch5 is Make_Iteration_Scheme (Loc, Condition => Cond), Statements => Stats, End_Label => Empty); + + -- If the range of iteration is given by a function call that + -- returns a container, the finalization actions have been saved + -- in the Condition_Actions of the iterator. Insert them now at + -- the head of the loop. + + if Present (Condition_Actions (Isc)) then + Insert_List_Before (N, Condition_Actions (Isc)); + end if; end; end if; @@ -3158,6 +3167,7 @@ package body Exp_Ch5 is elsif Present (Isc) and then Present (Condition_Actions (Isc)) + and then Present (Condition (Isc)) then declare ES : Node_Id; diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 1a5bdd40db2..bd0f9187cc6 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1919,7 +1919,11 @@ package body Sem_Ch5 is Set_Current_Value_Condition (N); return; + -- For an iterator specification with "of", pre-analyze range to + -- capture function calls that may require finalization actions. + elsif Present (Iterator_Specification (N)) then + Pre_Analyze_Range (Name (Iterator_Specification (N))); Analyze_Iterator_Specification (Iterator_Specification (N)); -- Else we have a FOR loop @@ -1974,7 +1978,7 @@ package body Sem_Ch5 is then Process_Bounds (DS); - -- Expander not active or else domain of iteration is a subtype + -- expander not active or else range of iteration is a subtype -- indication, an entity, or a function call that yields an -- aggregate or a container. @@ -1989,7 +1993,8 @@ package body Sem_Ch5 is and then not Is_Type (Entity (D_Copy))) then -- This is an iterator specification. Rewrite as such - -- and analyze. + -- and analyze, to capture function calls that may + -- require finalization actions. declare I_Spec : constant Node_Id := @@ -1997,8 +2002,7 @@ package body Sem_Ch5 is Defining_Identifier => Relocate_Node (Id), Name => D_Copy, - Subtype_Indication => - Empty, + Subtype_Indication => Empty, Reverse_Present => Reverse_Present (LP)); begin -- 2.30.2