Commit 061828e3 by Arnaud Charlet

[multiple changes]

2014-01-20  Robert Dewar  <dewar@adacore.com>

	* s-tataat.adb: Minor reformatting.

2014-01-20  Robert Dewar  <dewar@adacore.com>

	* einfo.adb (Is_Descendent_Of_Address): Now applies to all
	entities, and also fix documentation to remove mention of visible
	integer type, since this is not what the implementation does.
	* einfo.ads (Is_Descendent_Of_Address): Now applies to all
	entities, and also fix documentation to remove mention of visible
	integer type, since this is not what the implementation does.
	* gnat_rm.texi: Minor clarification of Allow_Integer_Address
	function.
	* sem_ch4.adb (Analyze_One_Call): Handle Allow_Integer_Address
	case for parameter type check.
	* sem_res.adb (Resolve): Use new function
	Address_Integer_Convert_OK.
	* sem_type.adb: Minor code reorganization (use Ekind_In) Minor
	reformatting throughout.
	* sem_util.adb (Address_Integer_Convert_OK): New function.
	* sem_util.ads: Minor reformatting (put specs in alpha order)
	(Address_Integer_Convert_OK): New function.

2014-01-20  Thomas Quinot  <quinot@adacore.com>

	* exp_ch7.adb (Wrap_Transient_Expression):
	Insertion extra conditional expression only if
	Opt.Suppress_Control_Flow_Optimizations is set.

From-SVN: r206832
parent ff4e28eb
2014-01-20 Robert Dewar <dewar@adacore.com>
* s-tataat.adb: Minor reformatting.
2014-01-20 Robert Dewar <dewar@adacore.com>
* einfo.adb (Is_Descendent_Of_Address): Now applies to all
entities, and also fix documentation to remove mention of visible
integer type, since this is not what the implementation does.
* einfo.ads (Is_Descendent_Of_Address): Now applies to all
entities, and also fix documentation to remove mention of visible
integer type, since this is not what the implementation does.
* gnat_rm.texi: Minor clarification of Allow_Integer_Address
function.
* sem_ch4.adb (Analyze_One_Call): Handle Allow_Integer_Address
case for parameter type check.
* sem_res.adb (Resolve): Use new function
Address_Integer_Convert_OK.
* sem_type.adb: Minor code reorganization (use Ekind_In) Minor
reformatting throughout.
* sem_util.adb (Address_Integer_Convert_OK): New function.
* sem_util.ads: Minor reformatting (put specs in alpha order)
(Address_Integer_Convert_OK): New function.
2014-01-20 Thomas Quinot <quinot@adacore.com>
* exp_ch7.adb (Wrap_Transient_Expression):
Insertion extra conditional expression only if
Opt.Suppress_Control_Flow_Optimizations is set.
2014-01-20 Arnaud Charlet <charlet@adacore.com> 2014-01-20 Arnaud Charlet <charlet@adacore.com>
* s-tataat.adb (Initialize_Attributes): Abort might already be * s-tataat.adb (Initialize_Attributes): Abort might already be
......
...@@ -1927,7 +1927,6 @@ package body Einfo is ...@@ -1927,7 +1927,6 @@ package body Einfo is
function Is_Descendent_Of_Address (Id : E) return B is function Is_Descendent_Of_Address (Id : E) return B is
begin begin
pragma Assert (Is_Type (Id));
return Flag223 (Id); return Flag223 (Id);
end Is_Descendent_Of_Address; end Is_Descendent_Of_Address;
......
...@@ -2216,10 +2216,8 @@ package Einfo is ...@@ -2216,10 +2216,8 @@ package Einfo is
-- types and subtypes. -- types and subtypes.
-- Is_Descendent_Of_Address (Flag223) -- Is_Descendent_Of_Address (Flag223)
-- Defined in all type and subtype entities. Indicates that a type is an -- Defined in all entities. True if the entity is type System.Address,
-- address type that is visibly a numeric type. Used for semantic checks -- or (recursively) a subtype or derived type of System.Address.
-- on VMS to remove ambiguities in universal integer expressions that may
-- have an address interpretation
-- Is_Discrete_Type (synthesized) -- Is_Discrete_Type (synthesized)
-- Applies to all entities, true for all discrete types and subtypes -- Applies to all entities, true for all discrete types and subtypes
...@@ -4961,6 +4959,7 @@ package Einfo is ...@@ -4961,6 +4959,7 @@ package Einfo is
-- Is_Child_Unit (Flag73) -- Is_Child_Unit (Flag73)
-- Is_Compilation_Unit (Flag149) -- Is_Compilation_Unit (Flag149)
-- Is_Completely_Hidden (Flag103) -- Is_Completely_Hidden (Flag103)
-- Is_Descendent_Of_Address (Flag223)
-- Is_Discrim_SO_Function (Flag176) -- Is_Discrim_SO_Function (Flag176)
-- Is_Dispatch_Table_Entity (Flag234) -- Is_Dispatch_Table_Entity (Flag234)
-- Is_Dispatching_Operation (Flag6) -- Is_Dispatching_Operation (Flag6)
...@@ -6451,6 +6450,7 @@ package Einfo is ...@@ -6451,6 +6450,7 @@ package Einfo is
function Is_Constructor (Id : E) return B; function Is_Constructor (Id : E) return B;
function Is_Controlled (Id : E) return B; function Is_Controlled (Id : E) return B;
function Is_Controlling_Formal (Id : E) return B; function Is_Controlling_Formal (Id : E) return B;
function Is_Descendent_Of_Address (Id : E) return B;
function Is_Discrim_SO_Function (Id : E) return B; function Is_Discrim_SO_Function (Id : E) return B;
function Is_Dispatch_Table_Entity (Id : E) return B; function Is_Dispatch_Table_Entity (Id : E) return B;
function Is_Dispatching_Operation (Id : E) return B; function Is_Dispatching_Operation (Id : E) return B;
...@@ -6666,7 +6666,6 @@ package Einfo is ...@@ -6666,7 +6666,6 @@ package Einfo is
function Is_Concurrent_Type (Id : E) return B; function Is_Concurrent_Type (Id : E) return B;
function Is_Decimal_Fixed_Point_Type (Id : E) return B; function Is_Decimal_Fixed_Point_Type (Id : E) return B;
function Is_Digits_Type (Id : E) return B; function Is_Digits_Type (Id : E) return B;
function Is_Descendent_Of_Address (Id : E) return B;
function Is_Discrete_Or_Fixed_Point_Type (Id : E) return B; function Is_Discrete_Or_Fixed_Point_Type (Id : E) return B;
function Is_Discrete_Type (Id : E) return B; function Is_Discrete_Type (Id : E) return B;
function Is_Elementary_Type (Id : E) return B; function Is_Elementary_Type (Id : E) return B;
......
...@@ -7982,16 +7982,13 @@ package body Exp_Ch7 is ...@@ -7982,16 +7982,13 @@ package body Exp_Ch7 is
-- end; -- end;
-- A special case is made for Boolean expressions so that the back-end -- A special case is made for Boolean expressions so that the back-end
-- knows to generate a conditional branch instruction if running with -- knows to generate a conditional branch instruction, if running with
-- -fpreserve-control-flow. This ensures that a control flow change -- -fpreserve-control-flow. This ensures that a control flow change
-- signalling the decision outcome occurs before the cleanup actions. -- signalling the decision outcome occurs before the cleanup actions.
-- In the absence of -fpreserve-control-flow, the back-end will
-- optimize away the extra conditional expression, so we can do this
-- modification unconditionally here.
-- Why don't we add a test of Opt.Preserve_Control_Flow here??? if Opt.Suppress_Control_Flow_Optimizations
and then Is_Boolean_Type (Typ)
if Is_Boolean_Type (Typ) then then
Expr := Expr :=
Make_If_Expression (Loc, Make_If_Expression (Loc,
Expressions => New_List ( Expressions => New_List (
......
...@@ -1263,6 +1263,12 @@ package AddrAsInt is ...@@ -1263,6 +1263,12 @@ package AddrAsInt is
end AddrAsInt; end AddrAsInt;
@end smallexample @end smallexample
@noindent
Note that these automatic conversions do not apply to expressions used
as subprogram arguments, because in general overloading can take place,
so that the required type is not fixed by the context. If necessary
adjust the type of the subprogram argument, e.g. by adding a conversion.
@node Pragma Annotate @node Pragma Annotate
@unnumberedsec Pragma Annotate @unnumberedsec Pragma Annotate
@findex Annotate @findex Annotate
......
...@@ -186,6 +186,9 @@ package body System.Tasking.Task_Attributes is ...@@ -186,6 +186,9 @@ package body System.Tasking.Task_Attributes is
Self_Id : constant Task_Id := Self; Self_Id : constant Task_Id := Self;
begin begin
-- Note: we call [Un]Defer_Abort_Nestable, rather than [Un]Defer_Abort,
-- because Abort might already be deferred in Create_Task.
Defer_Abort_Nestable (Self_Id); Defer_Abort_Nestable (Self_Id);
Lock_RTS; Lock_RTS;
......
...@@ -3189,6 +3189,23 @@ package body Sem_Ch4 is ...@@ -3189,6 +3189,23 @@ package body Sem_Ch4 is
Next_Actual (Actual); Next_Actual (Actual);
Next_Formal (Formal); Next_Formal (Formal);
-- In Allow_Integer_Address mode, we allow an actual integer to
-- match a formal address type and vice versa. We only do this
-- if we are certain that an error will otherwise be issued
elsif Address_Integer_Convert_OK
(Etype (Actual), Etype (Formal))
and then (Report and not Is_Indexed and not Is_Indirect)
then
-- Handle this case by introducing an unchecked conversion
Rewrite (Actual,
Unchecked_Convert_To (Etype (Formal),
Relocate_Node (Actual)));
Analyze_And_Resolve (Actual, Etype (Formal));
Next_Actual (Actual);
Next_Formal (Formal);
else else
if Debug_Flag_E then if Debug_Flag_E then
Write_Str (" type checking fails in call "); Write_Str (" type checking fails in call ");
...@@ -3200,6 +3217,8 @@ package body Sem_Ch4 is ...@@ -3200,6 +3217,8 @@ package body Sem_Ch4 is
Write_Eol; Write_Eol;
end if; end if;
-- Comment needed on the following test???
if Report and not Is_Indexed and not Is_Indirect then if Report and not Is_Indexed and not Is_Indirect then
-- Ada 2005 (AI-251): Complete the error notification -- Ada 2005 (AI-251): Complete the error notification
......
...@@ -2619,17 +2619,10 @@ package body Sem_Res is ...@@ -2619,17 +2619,10 @@ package body Sem_Res is
-- treated as an Address. The reverse case of integer wanted, -- treated as an Address. The reverse case of integer wanted,
-- Address found, is treated in an analogous manner. -- Address found, is treated in an analogous manner.
if Allow_Integer_Address then if Address_Integer_Convert_OK (Typ, Etype (N)) then
if (Is_RTE (Typ, RE_Address) Rewrite (N, Unchecked_Convert_To (Typ, Relocate_Node (N)));
and then Is_Integer_Type (Etype (N))) Analyze_And_Resolve (N, Typ);
or else return;
(Is_Integer_Type (Typ)
and then Is_RTE (Etype (N), RE_Address))
then
Rewrite (N, Unchecked_Convert_To (Typ, Relocate_Node (N)));
Analyze_And_Resolve (N, Typ);
return;
end if;
end if; end if;
-- That special Allow_Integer_Address check did not appply, so we -- That special Allow_Integer_Address check did not appply, so we
...@@ -11095,14 +11088,7 @@ package body Sem_Res is ...@@ -11095,14 +11088,7 @@ package body Sem_Res is
-- Allow_Integer_Address is in effect. We convert the conversion to -- Allow_Integer_Address is in effect. We convert the conversion to
-- an unchecked conversion in this case and we are all done! -- an unchecked conversion in this case and we are all done!
if Allow_Integer_Address if Address_Integer_Convert_OK (Opnd_Type, Target_Type) then
and then
((Is_RTE (Target_Type, RE_Address)
and then Is_Integer_Type (Opnd_Type))
or else
(Is_RTE (Opnd_Type, RE_Address)
and then Is_Integer_Type (Target_Type)))
then
Rewrite (N, Unchecked_Convert_To (Target_Type, Expression (N))); Rewrite (N, Unchecked_Convert_To (Target_Type, Expression (N)));
Analyze_And_Resolve (N, Target_Type); Analyze_And_Resolve (N, Target_Type);
return True; return True;
......
...@@ -361,6 +361,27 @@ package body Sem_Util is ...@@ -361,6 +361,27 @@ package body Sem_Util is
Analyze (N); Analyze (N);
end Add_Global_Declaration; end Add_Global_Declaration;
--------------------------------
-- Address_Integer_Convert_OK --
--------------------------------
function Address_Integer_Convert_OK (T1, T2 : Entity_Id) return Boolean is
begin
if Allow_Integer_Address
and then ((Is_Descendent_Of_Address (T1)
and then Is_Private_Type (T1)
and then Is_Integer_Type (T2))
or else
(Is_Descendent_Of_Address (T2)
and then Is_Private_Type (T2)
and then Is_Integer_Type (T1)))
then
return True;
else
return False;
end if;
end Address_Integer_Convert_OK;
----------------- -----------------
-- Addressable -- -- Addressable --
----------------- -----------------
......
...@@ -67,6 +67,11 @@ package Sem_Util is ...@@ -67,6 +67,11 @@ package Sem_Util is
-- for the current unit. The declarations are added in the current scope, -- for the current unit. The declarations are added in the current scope,
-- so the caller should push a new scope as required before the call. -- so the caller should push a new scope as required before the call.
function Address_Integer_Convert_OK (T1, T2 : Entity_Id) return Boolean;
-- Given two types, returns True if we are in Allow_Integer_Address mode
-- and one of the types is (a descendent of) System.Address (and this type
-- is private), and the other type is any integer type.
function Addressable (V : Uint) return Boolean; function Addressable (V : Uint) return Boolean;
function Addressable (V : Int) return Boolean; function Addressable (V : Int) return Boolean;
pragma Inline (Addressable); pragma Inline (Addressable);
...@@ -398,12 +403,12 @@ package Sem_Util is ...@@ -398,12 +403,12 @@ package Sem_Util is
-- * Array-of-scalars with specified Default_Component_Value -- * Array-of-scalars with specified Default_Component_Value
-- * Array type with fully default initialized component type -- * Array type with fully default initialized component type
-- * Record or protected type with components that either have a -- * Record or protected type with components that either have a
-- default expression or their related types are fully default -- default expression or their related types are fully default
-- initialized. -- initialized.
-- * Scalar type with specified Default_Value -- * Scalar type with specified Default_Value
-- * Task type -- * Task type
-- * Type extension of a type with full default initialization where -- * Type extension of a type with full default initialization where
-- the extension components are also fully default initialized -- the extension components are also fully default initialized.
Mixed_Initialization, Mixed_Initialization,
-- This value applies to a type where some of its internals are fully -- This value applies to a type where some of its internals are fully
...@@ -415,8 +420,7 @@ package Sem_Util is ...@@ -415,8 +420,7 @@ package Sem_Util is
function Default_Initialization function Default_Initialization
(Typ : Entity_Id) return Default_Initialization_Kind; (Typ : Entity_Id) return Default_Initialization_Kind;
-- Determine the default initialization kind that applies to a particular -- Determine default initialization kind that applies to a particular type
-- type.
function Deepest_Type_Access_Level (Typ : Entity_Id) return Uint; function Deepest_Type_Access_Level (Typ : Entity_Id) return Uint;
-- Same as Type_Access_Level, except that if the type is the type of an Ada -- Same as Type_Access_Level, except that if the type is the type of an Ada
...@@ -973,6 +977,20 @@ package Sem_Util is ...@@ -973,6 +977,20 @@ package Sem_Util is
function Is_CPP_Constructor_Call (N : Node_Id) return Boolean; function Is_CPP_Constructor_Call (N : Node_Id) return Boolean;
-- Returns True if N is a call to a CPP constructor -- Returns True if N is a call to a CPP constructor
function Is_Child_Or_Sibling
(Pack_1 : Entity_Id;
Pack_2 : Entity_Id;
Private_Child : Boolean) return Boolean;
-- Determine the following relations between two arbitrary packages:
-- 1) One package is the parent of a child package
-- 2) Both packages are siblings and share a common parent
-- If flag Private_Child is set, then the child in case 1) or both siblings
-- in case 2) must be private.
function Is_Concurrent_Interface (T : Entity_Id) return Boolean;
-- First determine whether type T is an interface and then check whether
-- it is of protected, synchronized or task kind.
function Is_Dependent_Component_Of_Mutable_Object function Is_Dependent_Component_Of_Mutable_Object
(Object : Node_Id) return Boolean; (Object : Node_Id) return Boolean;
-- Returns True if Object is the name of a subcomponent that depends on -- Returns True if Object is the name of a subcomponent that depends on
...@@ -991,20 +1009,6 @@ package Sem_Util is ...@@ -991,20 +1009,6 @@ package Sem_Util is
-- This is the RM definition, a type is a descendent of another type if it -- This is the RM definition, a type is a descendent of another type if it
-- is the same type or is derived from a descendent of the other type. -- is the same type or is derived from a descendent of the other type.
function Is_Child_Or_Sibling
(Pack_1 : Entity_Id;
Pack_2 : Entity_Id;
Private_Child : Boolean) return Boolean;
-- Determine the following relations between two arbitrary packages:
-- 1) One package is the parent of a child package
-- 2) Both packages are siblings and share a common parent
-- If flag Private_Child is set, then the child in case 1) or both siblings
-- in case 2) must be private.
function Is_Concurrent_Interface (T : Entity_Id) return Boolean;
-- First determine whether type T is an interface and then check whether
-- it is of protected, synchronized or task kind.
function Is_Expression_Function (Subp : Entity_Id) return Boolean; function Is_Expression_Function (Subp : Entity_Id) return Boolean;
-- Predicate to determine whether a scope entity comes from a rewritten -- Predicate to determine whether a scope entity comes from a rewritten
-- expression function call, and should be inlined unconditionally. Also -- expression function call, and should be inlined unconditionally. Also
......
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