From: Arnaud Charlet Date: Mon, 2 Mar 2015 13:49:31 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cd1a470ab20ef25928fdf69085bb178339872468;p=gcc.git [multiple changes] 2015-03-02 Robert Dewar * scng.adb (Scan): Ignore illegal character in relaxed semantics mode. 2015-03-02 Ed Schonberg * sem_ch4.adb (Analyze_Set_Membership); Retain Overloaded flag on left operand, so it can be properly resolved with type of alternatives of right operand. * sem_res.adb (Resolve_Set_Membership): Handle properly an overloaded left-hand side when the alternatives on the right hand side are literals of some universal type. Use first non-overloaded alternative to find expected type. 2015-03-02 Ed Schonberg * exp_ch7.adb (Make_Set_Finalize_Address_Call): Use underlying type to retrieve designated type, because the purported access type may be a partial (private) view, when it is declared in the private part of a nested package, and finalization actions are generated when completing compilation of enclosing unit. From-SVN: r221116 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d5da4d8a67c..6a7a17ca8b6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,26 @@ +2015-03-02 Robert Dewar + + * scng.adb (Scan): Ignore illegal character in relaxed + semantics mode. + +2015-03-02 Ed Schonberg + + * sem_ch4.adb (Analyze_Set_Membership); Retain Overloaded flag + on left operand, so it can be properly resolved with type of + alternatives of right operand. + * sem_res.adb (Resolve_Set_Membership): Handle properly an + overloaded left-hand side when the alternatives on the right + hand side are literals of some universal type. Use first + non-overloaded alternative to find expected type. + +2015-03-02 Ed Schonberg + + * exp_ch7.adb (Make_Set_Finalize_Address_Call): Use underlying + type to retrieve designated type, because the purported access + type may be a partial (private) view, when it is declared in + the private part of a nested package, and finalization actions + are generated when completing compilation of enclosing unit. + 2015-03-02 Robert Dewar * back_end.adb (Call_Back_End): Remove previous patch, diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index a9a242e9b23..52dfb4ebc2f 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -7853,10 +7853,19 @@ package body Exp_Ch7 is (Loc : Source_Ptr; Ptr_Typ : Entity_Id) return Node_Id is + + -- It is possible for Ptr_Typ to be a partial view, if the access + -- type is a full view declared in the private part of a nested package, + -- and the finalization actions take place when completing analysis + -- of the enclosing unit. For this reason we use Underlying_Type + -- in two places below. + Desig_Typ : constant Entity_Id := - Available_View (Designated_Type (Ptr_Typ)); + Available_View + (Designated_Type (Underlying_Type (Ptr_Typ))); Fin_Addr : constant Entity_Id := Finalize_Address (Desig_Typ); - Fin_Mas : constant Entity_Id := Finalization_Master (Ptr_Typ); + Fin_Mas : constant Entity_Id := + Finalization_Master (Underlying_Type (Ptr_Typ)); begin -- Both the finalization master and primitive Finalize_Address must be diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index 3e31e5af82d..7bf8ea2eacc 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, 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- -- @@ -1757,10 +1757,15 @@ package body Scng is then Scan_Ptr := Scan_Ptr + 1; - -- Otherwise we have an illegal comment character + -- Otherwise we have an illegal comment character, ignore + -- this error in relaxed semantics mode. else - Error_Illegal_Character; + if Relaxed_RM_Semantics then + Scan_Ptr := Scan_Ptr + 1; + else + Error_Illegal_Character; + end if; end if; end loop; diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 1d33d1b2ce2..c943df19b16 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2683,7 +2683,9 @@ package body Sem_Ch4 is if Present (Common_Type) then Set_Etype (L, Common_Type); - Set_Is_Overloaded (L, False); + + -- The left operand may still be overloaded, to be resolved using + -- the Common_Type. else Error_Msg_N ("cannot resolve membership operation", N); diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index de6cef94d76..69cd3396de7 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8593,9 +8593,35 @@ package body Sem_Res is procedure Resolve_Set_Membership is Alt : Node_Id; - Ltyp : constant Entity_Id := Etype (L); + Ltyp : Entity_Id; begin + -- If the left operand is overloaded, find type compatible with not + -- overloaded alternative of the right operand. + + if Is_Overloaded (L) then + Ltyp := Empty; + Alt := First (Alternatives (N)); + while Present (Alt) loop + if not Is_Overloaded (Alt) then + Ltyp := Intersect_Types (L, Alt); + exit; + else + Next (Alt); + end if; + end loop; + + -- Unclear how to resolve expression if all alternatives are also + -- overloaded. + + if No (Ltyp) then + Error_Msg_N ("ambiguous expression", N); + end if; + + else + Ltyp := Etype (L); + end if; + Resolve (L, Ltyp); Alt := First (Alternatives (N));