Commit 1a779058 by Arnaud Charlet

[multiple changes]

2015-01-06  Thomas Quinot  <quinot@adacore.com>

	* freeze.adb (Set_SSO_From_Defaults): When setting scalar storage
	order to native from default, make sure to also adjust bit order.
	* exp_aggr.adb: Minor reformatting.

2015-01-06  Robert Dewar  <dewar@adacore.com>

	* s-valllu.adb, s-valllu.ads, s-valuti.ads, s-valuns.adb, s-valuns.ads,
	s-valrea.adb, s-valrea.ads: Add some additional guards for
	Str'Last = Positive'Last.

2015-01-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch12.adb, sem_ch8.adb: Ongoing work for wrappers for actual
	subprograms.

2015-01-06  Javier Miranda  <miranda@adacore.com>

	* exp_disp.adb (Expand_Interface_Conversion): Reapply patch.

From-SVN: r219250
parent 375cbc2b
2015-01-06 Thomas Quinot <quinot@adacore.com> 2015-01-06 Thomas Quinot <quinot@adacore.com>
* freeze.adb (Set_SSO_From_Defaults): When setting scalar storage
order to native from default, make sure to also adjust bit order.
* exp_aggr.adb: Minor reformatting.
2015-01-06 Robert Dewar <dewar@adacore.com>
* s-valllu.adb, s-valllu.ads, s-valuti.ads, s-valuns.adb, s-valuns.ads,
s-valrea.adb, s-valrea.ads: Add some additional guards for
Str'Last = Positive'Last.
2015-01-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb, sem_ch8.adb: Ongoing work for wrappers for actual
subprograms.
2015-01-06 Javier Miranda <miranda@adacore.com>
* exp_disp.adb (Expand_Interface_Conversion): Reapply patch.
2015-01-06 Thomas Quinot <quinot@adacore.com>
* sem_util.ads: Minor reformatting. * sem_util.ads: Minor reformatting.
* sem_cat.adb (In_RCI_Visible_Declarations): Change back to... * sem_cat.adb (In_RCI_Visible_Declarations): Change back to...
(In_RCI_Declaration) Return to old name, as proper checking of (In_RCI_Declaration) Return to old name, as proper checking of
......
...@@ -239,10 +239,10 @@ package body Exp_Aggr is ...@@ -239,10 +239,10 @@ package body Exp_Aggr is
-- Packed_Array_Aggregate_Handled, we set this parameter to True, since -- Packed_Array_Aggregate_Handled, we set this parameter to True, since
-- these are cases we handle in there. -- these are cases we handle in there.
-- It would seem worthwhile to have a higher default value for Max_Others_ -- It would seem useful to have a higher default for Max_Others_Replicate,
-- replicate, but aggregates in the compiler make this impossible: the -- but aggregates in the compiler make this impossible: the compiler
-- compiler bootstrap fails if Max_Others_Replicate is greater than 25. -- bootstrap fails if Max_Others_Replicate is greater than 25. This
-- This is unexpected ??? -- is unexpected ???
procedure Expand_Array_Aggregate (N : Node_Id); procedure Expand_Array_Aggregate (N : Node_Id);
-- This is the top-level routine to perform array aggregate expansion. -- This is the top-level routine to perform array aggregate expansion.
......
...@@ -1138,6 +1138,25 @@ package body Exp_Disp is ...@@ -1138,6 +1138,25 @@ package body Exp_Disp is
Operand_Typ := Base_Type (Corresponding_Record_Type (Operand_Typ)); Operand_Typ := Base_Type (Corresponding_Record_Type (Operand_Typ));
end if; end if;
-- No displacement of the pointer to the object needed when the type of
-- the operand is not an interface type and the interface is one of
-- its parent types (since they share the primary dispatch table).
declare
Opnd : Entity_Id := Operand_Typ;
begin
if Is_Access_Type (Opnd) then
Opnd := Designated_Type (Opnd);
end if;
if not Is_Interface (Opnd)
and then Is_Ancestor (Iface_Typ, Opnd, Use_Full_View => True)
then
return;
end if;
end;
-- Evaluate if we can statically displace the pointer to the object -- Evaluate if we can statically displace the pointer to the object
declare declare
......
...@@ -7748,6 +7748,8 @@ package body Freeze is ...@@ -7748,6 +7748,8 @@ package body Freeze is
-------------------------- --------------------------
procedure Set_SSO_From_Default (T : Entity_Id) is procedure Set_SSO_From_Default (T : Entity_Id) is
Reversed : Boolean;
begin begin
-- Set default SSO for an array or record base type, except in case of -- Set default SSO for an array or record base type, except in case of
-- a type extension (which always inherits the SSO of its parent type). -- a type extension (which always inherits the SSO of its parent type).
...@@ -7758,31 +7760,35 @@ package body Freeze is ...@@ -7758,31 +7760,35 @@ package body Freeze is
and then not (Is_Tagged_Type (T) and then not (Is_Tagged_Type (T)
and then Is_Derived_Type (T)))) and then Is_Derived_Type (T))))
then then
if ((Bytes_Big_Endian and then SSO_Set_Low_By_Default (T)) Reversed :=
or else (Bytes_Big_Endian and then SSO_Set_Low_By_Default (T))
((not Bytes_Big_Endian) and then SSO_Set_High_By_Default (T))) or else
(not Bytes_Big_Endian and then SSO_Set_High_By_Default (T));
if (SSO_Set_Low_By_Default (T) or else SSO_Set_High_By_Default (T))
-- For a record type, if native bit order is specified explicitly, -- For a record type, if bit order is specified explicitly, then
-- then never set reverse SSO from default. -- do not set SSO from default if not consistent.
and then not and then not
(Is_Record_Type (T) (Is_Record_Type (T)
and then Has_Rep_Item (T, Name_Bit_Order) and then Has_Rep_Item (T, Name_Bit_Order)
and then not Reverse_Bit_Order (T)) and then Reverse_Bit_Order (T) /= Reversed)
then then
-- If flags cause reverse storage order, then set the result. Note -- If flags cause reverse storage order, then set the result. Note
-- that we would have ignored the pragma setting the non default -- that we would have ignored the pragma setting the non default
-- storage order in any case, hence the assertion at this point. -- storage order in any case, hence the assertion at this point.
pragma Assert (Support_Nondefault_SSO_On_Target); pragma Assert
Set_Reverse_Storage_Order (T); (not Reversed or else Support_Nondefault_SSO_On_Target);
Set_Reverse_Storage_Order (T, Reversed);
-- For a record type, also set reversed bit order. Note that if -- For a record type, also set reversed bit order. Note: if a bit
-- a bit order has been specified explicitly, then this is a -- order has been specified explicitly, then this is a no-op.
-- no-op, as per the guard above.
if Is_Record_Type (T) then if Is_Record_Type (T) then
Set_Reverse_Bit_Order (T); Set_Reverse_Bit_Order (T, Reversed);
end if; end if;
end if; end if;
end if; end if;
......
...@@ -65,6 +65,13 @@ package body System.Val_LLU is ...@@ -65,6 +65,13 @@ package body System.Val_LLU is
-- Digit value -- Digit value
begin begin
-- We do not tolerate strings with Str'Last = Positive'Last
if Str'Last = Positive'Last then
raise Program_Error with
"string upper bound is Positive'Last, not supported";
end if;
P := Ptr.all; P := Ptr.all;
Uval := Character'Pos (Str (P)) - Character'Pos ('0'); Uval := Character'Pos (Str (P)) - Character'Pos ('0');
P := P + 1; P := P + 1;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -66,6 +66,10 @@ package System.Val_LLU is ...@@ -66,6 +66,10 @@ package System.Val_LLU is
-- Note: if Str is empty, i.e. if Max is less than Ptr, then this is a -- Note: if Str is empty, i.e. if Max is less than Ptr, then this is a
-- special case of an all-blank string, and Ptr is unchanged, and hence -- special case of an all-blank string, and Ptr is unchanged, and hence
-- is greater than Max as required in this case. -- is greater than Max as required in this case.
--
-- Note: this routine should not be called with Str'Last = Positive'Last.
-- If this occurs Program_Error is raised with a message noting that this
-- case is not supported. Most such cases are eliminated by the caller.
function Scan_Long_Long_Unsigned function Scan_Long_Long_Unsigned
(Str : String; (Str : String;
...@@ -73,6 +77,7 @@ package System.Val_LLU is ...@@ -73,6 +77,7 @@ package System.Val_LLU is
Max : Integer) return System.Unsigned_Types.Long_Long_Unsigned; Max : Integer) return System.Unsigned_Types.Long_Long_Unsigned;
-- Same as Scan_Raw_Long_Long_Unsigned, except scans optional leading -- Same as Scan_Raw_Long_Long_Unsigned, except scans optional leading
-- blanks, and an optional leading plus sign. -- blanks, and an optional leading plus sign.
--
-- Note: if a minus sign is present, Constraint_Error will be raised. -- Note: if a minus sign is present, Constraint_Error will be raised.
-- Note: trailing blanks are not scanned. -- Note: trailing blanks are not scanned.
......
...@@ -152,6 +152,13 @@ package body System.Val_Real is ...@@ -152,6 +152,13 @@ package body System.Val_Real is
-- Start of processing for System.Scan_Real -- Start of processing for System.Scan_Real
begin begin
-- We do not tolerate strings with Str'Last = Positive'Last
if Str'Last = Positive'Last then
raise Program_Error with
"string upper bound is Positive'Last, not supported";
end if;
-- We call the floating-point processor reset routine so that we can -- We call the floating-point processor reset routine so that we can
-- be sure the floating-point processor is properly set for conversion -- be sure the floating-point processor is properly set for conversion
-- calls. This is notably need on Windows, where calls to the operating -- calls. This is notably need on Windows, where calls to the operating
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -60,6 +60,10 @@ package System.Val_Real is ...@@ -60,6 +60,10 @@ package System.Val_Real is
-- Note: if Str is null, i.e. if Max is less than Ptr, then this is a -- Note: if Str is null, i.e. if Max is less than Ptr, then this is a
-- special case of an all-blank string, and Ptr is unchanged, and hence -- special case of an all-blank string, and Ptr is unchanged, and hence
-- is greater than Max as required in this case. -- is greater than Max as required in this case.
--
-- Note: this routine should not be called with Str'Last = Positive'Last.
-- If this occurs Program_Error is raised with a message noting that this
-- case is not supported. Most such cases are eliminated by the caller.
function Value_Real (Str : String) return Long_Long_Float; function Value_Real (Str : String) return Long_Long_Float;
-- Used in computing X'Value (Str) where X is a floating-point type or an -- Used in computing X'Value (Str) where X is a floating-point type or an
......
...@@ -65,6 +65,13 @@ package body System.Val_Uns is ...@@ -65,6 +65,13 @@ package body System.Val_Uns is
-- Digit value -- Digit value
begin begin
-- We do not tolerate strings with Str'Last = Positive'Last
if Str'Last = Positive'Last then
raise Program_Error with
"string upper bound is Positive'Last, not supported";
end if;
P := Ptr.all; P := Ptr.all;
Uval := Character'Pos (Str (P)) - Character'Pos ('0'); Uval := Character'Pos (Str (P)) - Character'Pos ('0');
P := P + 1; P := P + 1;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -66,6 +66,10 @@ package System.Val_Uns is ...@@ -66,6 +66,10 @@ package System.Val_Uns is
-- Note: if Str is empty, i.e. if Max is less than Ptr, then this is a -- Note: if Str is empty, i.e. if Max is less than Ptr, then this is a
-- special case of an all-blank string, and Ptr is unchanged, and hence -- special case of an all-blank string, and Ptr is unchanged, and hence
-- is greater than Max as required in this case. -- is greater than Max as required in this case.
--
-- Note: this routine should not be called with Str'Last = Positive'Last.
-- If this occurs Program_Error is raised with a message noting that this
-- case is not supported. Most such cases are eliminated by the caller.
function Scan_Unsigned function Scan_Unsigned
(Str : String; (Str : String;
...@@ -73,6 +77,7 @@ package System.Val_Uns is ...@@ -73,6 +77,7 @@ package System.Val_Uns is
Max : Integer) return System.Unsigned_Types.Unsigned; Max : Integer) return System.Unsigned_Types.Unsigned;
-- Same as Scan_Raw_Unsigned, except scans optional leading -- Same as Scan_Raw_Unsigned, except scans optional leading
-- blanks, and an optional leading plus sign. -- blanks, and an optional leading plus sign.
--
-- Note: if a minus sign is present, Constraint_Error will be raised. -- Note: if a minus sign is present, Constraint_Error will be raised.
-- Note: trailing blanks are not scanned. -- Note: trailing blanks are not scanned.
......
...@@ -71,6 +71,9 @@ package System.Val_Util is ...@@ -71,6 +71,9 @@ package System.Val_Util is
-- special case of an all-blank string, and Ptr is unchanged, and hence -- special case of an all-blank string, and Ptr is unchanged, and hence
-- is greater than Max as required in this case. Constraint_Error is also -- is greater than Max as required in this case. Constraint_Error is also
-- raised in this case. -- raised in this case.
--
-- This routine must not be called with Str'Last = Positive'Last. There is
-- no check for this case, the caller must ensure this condition is met.
procedure Scan_Plus_Sign procedure Scan_Plus_Sign
(Str : String; (Str : String;
...@@ -95,6 +98,9 @@ package System.Val_Util is ...@@ -95,6 +98,9 @@ package System.Val_Util is
-- returning a suitable large value. If the base is zero, then any value -- returning a suitable large value. If the base is zero, then any value
-- is allowed, and otherwise the large value will either cause underflow -- is allowed, and otherwise the large value will either cause underflow
-- or overflow during the scaling process which is fine. -- or overflow during the scaling process which is fine.
--
-- This routine must not be called with Str'Last = Positive'Last. There is
-- no check for this case, the caller must ensure this condition is met.
procedure Scan_Trailing_Blanks (Str : String; P : Positive); procedure Scan_Trailing_Blanks (Str : String; P : Positive);
-- Checks that the remainder of the field Str (P .. Str'Last) is all -- Checks that the remainder of the field Str (P .. Str'Last) is all
...@@ -113,5 +119,8 @@ package System.Val_Util is ...@@ -113,5 +119,8 @@ package System.Val_Util is
-- where the underscore is invalid, Constraint_Error is raised with Ptr -- where the underscore is invalid, Constraint_Error is raised with Ptr
-- set appropriately, otherwise control returns with P incremented past -- set appropriately, otherwise control returns with P incremented past
-- the underscore. -- the underscore.
--
-- This routine must not be called with Str'Last = Positive'Last. There is
-- no check for this case, the caller must ensure this condition is met.
end System.Val_Util; end System.Val_Util;
...@@ -3457,19 +3457,18 @@ package body Sem_Ch8 is ...@@ -3457,19 +3457,18 @@ package body Sem_Ch8 is
-- points of call within an instance. Wrappers are generated if formal -- points of call within an instance. Wrappers are generated if formal
-- subprogram is subject to axiomatization. -- subprogram is subject to axiomatization.
-- The types in the wrapper profiles are obtained from (instances of)
-- the types of the formal subprogram.
if Is_Actual if Is_Actual
and then GNATprove_Mode and then GNATprove_Mode
and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec)) and then Present (Containing_Package_With_Ext_Axioms (Formal_Spec))
and then not Inside_A_Generic and then not Inside_A_Generic
then then
if Ekind (Old_S) = E_Function then if Ekind (Old_S) = E_Function then
Rewrite (N, Build_Function_Wrapper (New_S, Old_S)); Rewrite (N, Build_Function_Wrapper (Formal_Spec, Old_S));
Analyze (N); Analyze (N);
-- For wrappers of operators, the types are obtained from (the
-- instances of) the types of the formal subprogram, not from the
-- actual subprogram, that carries predefined types.
elsif Ekind (Old_S) = E_Operator then elsif Ekind (Old_S) = E_Operator then
Rewrite (N, Build_Operator_Wrapper (Formal_Spec, Old_S)); Rewrite (N, Build_Operator_Wrapper (Formal_Spec, Old_S));
Analyze (N); Analyze (N);
......
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