diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-04-25 12:28:45 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-04-25 12:28:45 +0200 |
commit | 0812b84e77d5b5d187ea4c75841e4569f016612f (patch) | |
tree | 1709a49cd2beccc5cb64451b8470a07e5801ea9d /gcc/ada/sem_util.adb | |
parent | 1355d3738f0cabb2029899b905305e728d75674a (diff) | |
download | gcc-0812b84e77d5b5d187ea4c75841e4569f016612f.zip gcc-0812b84e77d5b5d187ea4c75841e4569f016612f.tar.gz gcc-0812b84e77d5b5d187ea4c75841e4569f016612f.tar.bz2 |
[multiple changes]
2013-04-25 Robert Dewar <dewar@adacore.com>
* debug.adb: Remove d.X and d.Y entries and documentation.
* exp_ch4.adb (Expand_N_If_Expression): Remove special code used
if expression with actions not available (now always available).
(Expand_Short_Circuit_Operator): Same change.
* gnat1drv.adb (Adjust_Global_Switches) Remove setting
Use_Expression_With_Actions flag, since this is now obsolete.
* opt.ads (Use_Expression_Actions): Removed (always True now).
* sinfo.ads: Minor comment updates.
2013-04-25 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb (Check_Generic_Actuals): If an actual is an array
subtype whose base type is currently private, install full view
when compiling instance body.
2013-04-25 Ed Schonberg <schonberg@adacore.com>
* sem_disp.adb (Check_Dispatching_Operation): Refine checks for
AI05-0125: the check for a hidden primitive that may be overridden
by the new declaration is only performed if the declaration comes
from source, and it must carry an explicit overriding indicator.
2013-04-25 Hristian Kirtchev <kirtchev@adacore.com>
* einfo.adb (Abstract_States): The attribute now applies to
generic packages.
* sem_ch3.adb (Analyze_Object_Declaration): Check whether an
object declaration introduces an illegal hidden state.
* sem_prag.adb (Analyze_Abstract_State): Check whether a state
declaration introduces an illegal hidden state.
* sem_util.ads, sem_util.adb (Check_No_Hidden_State): New routine.
2013-04-25 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Is_Build_In_Place_Function_Call): The call may
be to a protected function, in which case the name in the call
is a selected component.
2013-04-25 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch4.adb (Analyze_Quantified_Expression):
Warn on a suspicious use of quantifier "some" when "all" was meant.
(No_Else_Or_Trivial_True): New routine.
From-SVN: r198287
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r-- | gcc/ada/sem_util.adb | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index d95f69d..bf032fd 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2125,6 +2125,98 @@ package body Sem_Util is end if; end Check_Nested_Access; + --------------------------- + -- Check_No_Hidden_State -- + --------------------------- + + procedure Check_No_Hidden_State (Id : Entity_Id) is + function Has_Null_Abstract_State (Pkg : Entity_Id) return Boolean; + -- Determine whether the entity of a package denoted by Pkg has a null + -- abstract state. + + ----------------------------- + -- Has_Null_Abstract_State -- + ----------------------------- + + function Has_Null_Abstract_State (Pkg : Entity_Id) return Boolean is + States : constant Elist_Id := Abstract_States (Pkg); + + begin + -- Check the first available state of the related package. A null + -- abstract state always appears as the sole element of the state + -- list. + + return + Present (States) + and then Is_Null_State (Node (First_Elmt (States))); + end Has_Null_Abstract_State; + + -- Local variables + + Context : Entity_Id := Empty; + Not_Visible : Boolean := False; + Scop : Entity_Id; + + -- Start of processing for Check_No_Hidden_State + + begin + pragma Assert (Ekind_In (Id, E_Abstract_State, E_Variable)); + + -- Find the proper context where the object or state appears + + Scop := Scope (Id); + while Present (Scop) loop + Context := Scop; + + -- Keep track of the context's visibility + + Not_Visible := Not_Visible or else In_Private_Part (Context); + + -- Prevent the search from going too far + + if Context = Standard_Standard then + return; + + -- Objects and states that appear immediately within a subprogram or + -- inside a construct nested within a subprogram do not introduce a + -- hidden state. They behave as local variable declarations. + + elsif Is_Subprogram (Context) then + return; + + -- When examining a package body, use the entity of the spec as it + -- carries the abstract state declarations. + + elsif Ekind (Context) = E_Package_Body then + Context := Spec_Entity (Context); + end if; + + -- Stop the traversal when a package subject to a null abstract state + -- has been found. + + if Ekind_In (Context, E_Generic_Package, E_Package) + and then Has_Null_Abstract_State (Context) + then + exit; + end if; + + Scop := Scope (Scop); + end loop; + + -- At this point we know that there is at least one package with a null + -- abstract state in visibility. Emit an error message unconditionally + -- if the entity being processed is a state because the placement of the + -- related package is irrelevant. This is not the case for objects as + -- the intermediate context matters. + + if Present (Context) + and then (Ekind (Id) = E_Abstract_State or else Not_Visible) + then + Error_Msg_N ("cannot introduce hidden state &", Id); + Error_Msg_NE ("\package & has null abstract state", Id, Context); + end if; + end Check_No_Hidden_State; + ------------------------------------------ -- Check_Potentially_Blocking_Operation -- ------------------------------------------ |