Commit a18d0b15 by Hristian Kirtchev Committed by Arnaud Charlet

sem_util.adb (Extensions_Visible_Status): Modify the logic to account for non-SPARK code.

2014-11-20  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_util.adb (Extensions_Visible_Status): Modify the logic to account
	for non-SPARK code.
	(Object_Access_Level): In ASIS mode, recognize
	a selected component with an implicit dereference so that it
	yields the same value with and without expansion.

From-SVN: r217839
parent 5fde9688
2014-11-20 Hristian Kirtchev <kirtchev@adacore.com>
* sem_util.adb (Extensions_Visible_Status): Modify the logic to account
for non-SPARK code.
(Object_Access_Level): In ASIS mode, recognize
a selected component with an implicit dereference so that it
yields the same value with and without expansion.
2014-11-20 Ed Schonberg <schonberg@adacore.com> 2014-11-20 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_Pragma, case Implemented): In ASIS * sem_prag.adb (Analyze_Pragma, case Implemented): In ASIS
......
...@@ -5929,68 +5929,62 @@ package body Sem_Util is ...@@ -5929,68 +5929,62 @@ package body Sem_Util is
Subp : Entity_Id; Subp : Entity_Id;
begin begin
if SPARK_Mode = On then -- When a formal parameter is subject to Extensions_Visible, the pragma
-- is stored in the contract of related subprogram.
-- When a formal parameter is subject to Extensions_Visible, the if Is_Formal (Id) then
-- pragma is stored in the contract of related subprogram. Subp := Scope (Id);
if Is_Formal (Id) then elsif Is_Subprogram_Or_Generic_Subprogram (Id) then
Subp := Scope (Id); Subp := Id;
elsif Is_Subprogram_Or_Generic_Subprogram (Id) then -- No other construct carries this pragma
Subp := Id;
-- No other construct carries this pragma else
return Extensions_Visible_None;
else end if;
return Extensions_Visible_None;
end if;
Prag := Get_Pragma (Subp, Pragma_Extensions_Visible);
-- Extract the value from the Boolean expression (if any)
if Present (Prag) then Prag := Get_Pragma (Subp, Pragma_Extensions_Visible);
Arg1 := First (Pragma_Argument_Associations (Prag));
-- The pragma appears with an argument -- Extract the value from the Boolean expression (if any)
if Present (Arg1) then if Present (Prag) then
Expr := Get_Pragma_Arg (Arg1); Arg1 := First (Pragma_Argument_Associations (Prag));
-- Guarg against cascading errors when the argument of pragma -- The pragma appears with an argument
-- Extensions_Visible is not a valid static Boolean expression.
if Error_Posted (Expr) then if Present (Arg1) then
return Extensions_Visible_None; Expr := Get_Pragma_Arg (Arg1);
elsif Is_True (Expr_Value (Expr)) then -- Guard against cascading errors when the argument of pragma
return Extensions_Visible_True; -- Extensions_Visible is not a valid static Boolean expression.
else if Error_Posted (Expr) then
return Extensions_Visible_False; return Extensions_Visible_None;
end if;
-- Otherwise the pragma defaults to True elsif Is_True (Expr_Value (Expr)) then
return Extensions_Visible_True;
else else
return Extensions_Visible_True; return Extensions_Visible_False;
end if; end if;
-- Otherwise pragma Expresions_Visible is not inherited or directly -- Otherwise the pragma defaults to True
-- specified, its value defaults to "False".
else else
return Extensions_Visible_False; return Extensions_Visible_True;
end if; end if;
-- When SPARK_Mode is disabled, all semantic checks related to pragma -- Otherwise pragma Extensions_Visible is not inherited or directly
-- Extensions_Visible are disabled as well. Instead of saturating the -- specified. In SPARK code, its value defaults to "False".
-- code with "if SPARK_Mode /= Off then" checks, the predicate returns
-- a default value. elsif SPARK_Mode = On then
return Extensions_Visible_False;
-- In non-SPARK code, pragma Extensions_Visible defaults to "True"
else else
return Extensions_Visible_None; return Extensions_Visible_True;
end if; end if;
end Extensions_Visible_Status; end Extensions_Visible_Status;
...@@ -15364,10 +15358,20 @@ package body Sem_Util is ...@@ -15364,10 +15358,20 @@ package body Sem_Util is
-- recursive call on the prefix, which will in turn check the level -- recursive call on the prefix, which will in turn check the level
-- of the prefix object of the selected discriminant. -- of the prefix object of the selected discriminant.
-- In Ada 2012, if the discriminant has implicit dereference and
-- the context is a selected component, treat this as an object of
-- unknown scope (see below). This is necessary in compile-only mode;
-- otherwise expansion will already have transformed the prefix into
-- a temporary.
if Nkind (Prefix (Obj)) = N_Selected_Component if Nkind (Prefix (Obj)) = N_Selected_Component
and then Ekind (Etype (Prefix (Obj))) = E_Anonymous_Access_Type and then Ekind (Etype (Prefix (Obj))) = E_Anonymous_Access_Type
and then and then
Ekind (Entity (Selector_Name (Prefix (Obj)))) = E_Discriminant Ekind (Entity (Selector_Name (Prefix (Obj)))) = E_Discriminant
and then
(not Has_Implicit_Dereference
(Entity (Selector_Name (Prefix (Obj))))
or else Nkind (Parent (Obj)) /= N_Selected_Component)
then then
return Object_Access_Level (Prefix (Obj)); return Object_Access_Level (Prefix (Obj));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment