From: Arnaud Charlet Date: Thu, 20 Nov 2014 11:00:44 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c05ba1f17969c3423e76bee3e863727c9cf28ca0;p=gcc.git [multiple changes] 2014-11-20 Ed Schonberg * sem_res.adb (Make_Call_Into_Operator): In ASIS mode, propagate back the resolved operands to the original call node, taking into account that the original call may have named associations. 2014-11-20 Hristian Kirtchev * inline.adb (Has_Some_Contract): Change the guard to test the Ekind of the entity rather than the Analyzed flag. This handles partially analyzed contexts. 2014-11-20 Ed Schonberg * sem_ch8.adb (Analyze_Object_Renaming): In Ada 83 mode, do not reject the renaming of a function result if the renaming does not come for source. 2014-11-20 Robert Dewar * exp_util.ads: Minor addition of ??? clause. 2014-11-20 Ed Schonberg * sem_util.adb (Is_Variable): For an Ada 2012 implicit dereference introduced for an indexing opertion, check that the type of the corresponding access discriminant is not an access to constant. 2014-11-20 Hristian Kirtchev * sem_ch6.adb (Find_Corresponding_Spec): Inherit the ghostness of the matching spec, the same way convention is inherited. From-SVN: r217835 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d2746e1511d..27f16af46f3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,38 @@ +2014-11-20 Ed Schonberg + + * sem_res.adb (Make_Call_Into_Operator): In ASIS mode, propagate + back the resolved operands to the original call node, taking + into account that the original call may have named associations. + +2014-11-20 Hristian Kirtchev + + * inline.adb (Has_Some_Contract): Change the + guard to test the Ekind of the entity rather than the Analyzed + flag. This handles partially analyzed contexts. + +2014-11-20 Ed Schonberg + + * sem_ch8.adb (Analyze_Object_Renaming): In Ada 83 mode, do + not reject the renaming of a function result if the renaming + does not come for source. + +2014-11-20 Robert Dewar + + * exp_util.ads: Minor addition of ??? clause. + +2014-11-20 Ed Schonberg + + * sem_util.adb (Is_Variable): For an Ada 2012 implicit + dereference introduced for an indexing opertion, check that the + type of the corresponding access discriminant is not an access + to constant. + +2014-11-20 Hristian Kirtchev + + * sem_ch6.adb (Find_Corresponding_Spec): Inherit + the ghostness of the matching spec, the same way convention + is inherited. + 2014-11-20 Eric Botcazou * sem_ch3.adb (Analyze_Object_Declaration): Swap a couple of diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 671b13a19b8..99e81ec86b2 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -511,6 +511,9 @@ package Exp_Util is -- Note: this function can be costly and must be invoked with special care. -- Possibly we could introduce a flag at parse time indicating the presence -- of an address clause to speed this up??? + -- + -- Note: currently this function does not scan the private part, that seems + -- like a potential bug ??? procedure Force_Evaluation (Exp : Node_Id; diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 13d0f918b36..c900cd394f3 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -1327,9 +1327,9 @@ package body Inline is begin -- A call to an expression function may precede the actual body which -- is inserted at the end of the enclosing declarations. Ensure that - -- the related entity is analyzed before inspecting the contract. + -- the related entity is decorated before inspecting the contract. - if Analyzed (Id) then + if Is_Subprogram_Or_Generic_Subprogram (Id) then Items := Contract (Id); return Present (Items) diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 11db3e4a690..832a3ea7ab0 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -7415,8 +7415,16 @@ package body Sem_Ch6 is -- spec to match a body, full conformance is expected. if In_Instance then + + -- Inherit the convention and "ghostness" of the matching + -- spec to ensure proper full and subtype conformance. + Set_Convention (Designator, Convention (E)); + if Is_Ghost_Entity (E) then + Set_Is_Ghost_Entity (Designator); + end if; + -- Skip past subprogram bodies and subprogram renamings that -- may appear to have a matching spec, but that aren't fully -- conformant with it. That can occur in cases where an diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 21d9e73d425..4edeac9afde 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -1058,10 +1058,11 @@ package body Sem_Ch8 is if Nkind (Nam) = N_Function_Call then case Ada_Version is - -- Usage is illegal in Ada 83 + -- Usage is illegal in Ada 83, but renamings are also introduced + -- during expansion, and error does not apply to those. when Ada_83 => - if Comes_From_Source (Nam) then + if Comes_From_Source (N) then Error_Msg_N ("(Ada 83) cannot rename function return object", Nam); end if; diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 0afa28cdc86..6e02a2583f0 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -1793,15 +1793,61 @@ package body Sem_Res is and then Nkind (N) in N_Op and then Nkind (Original_Node (N)) = N_Function_Call then - if Is_Binary then - Rewrite (First (Parameter_Associations (Original_Node (N))), - Relocate_Node (Left_Opnd (N))); - Rewrite (Next (First (Parameter_Associations (Original_Node (N)))), - Relocate_Node (Right_Opnd (N))); - else - Rewrite (First (Parameter_Associations (Original_Node (N))), - Relocate_Node (Right_Opnd (N))); - end if; + declare + L : constant Node_Id := Left_Opnd (N); + R : constant Node_Id := Right_Opnd (N); + + Old_First : constant Node_Id := + First (Parameter_Associations (Original_Node (N))); + Old_Sec : Node_Id; + + begin + if Is_Binary then + Old_Sec := Next (Old_First); + + -- If the original call has named associations, replace the + -- explicit actual parameter in the association with the proper + -- resolved operand. + + if Nkind (Old_First) = N_Parameter_Association then + if Chars (Selector_Name (Old_First)) = + Chars (First_Entity (Op_Id)) + then + Rewrite (Explicit_Actual_Parameter (Old_First), + Relocate_Node (L)); + else + Rewrite (Explicit_Actual_Parameter (Old_First), + Relocate_Node (R)); + end if; + + else + Rewrite (Old_First, Relocate_Node (L)); + end if; + + if Nkind (Old_Sec) = N_Parameter_Association then + if Chars (Selector_Name (Old_Sec)) = + Chars (First_Entity (Op_Id)) + then + Rewrite (Explicit_Actual_Parameter (Old_Sec), + Relocate_Node (L)); + else + Rewrite (Explicit_Actual_Parameter (Old_Sec), + Relocate_Node (R)); + end if; + + else + Rewrite (Old_Sec, Relocate_Node (R)); + end if; + + else + if Nkind (Old_First) = N_Parameter_Association then + Rewrite (Explicit_Actual_Parameter (Old_First), + Relocate_Node (R)); + else + Rewrite (Old_First, Relocate_Node (R)); + end if; + end if; + end; Set_Parent (Original_Node (N), Parent (N)); end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 5a9117c8734..dd2ba869f5c 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -12806,12 +12806,14 @@ package body Sem_Util is Is_Variable_Prefix (Original_Node (Prefix (N))); -- in Ada 2012, the dereference may have been added for a type with - -- a declared implicit dereference aspect. + -- a declared implicit dereference aspect. Check that it is not an + -- access to constant. elsif Nkind (N) = N_Explicit_Dereference and then Present (Etype (Orig_Node)) and then Ada_Version >= Ada_2012 and then Has_Implicit_Dereference (Etype (Orig_Node)) + and then not Is_Access_Constant (Etype (Prefix (N))) then return True;