Commit e9c12b91 by Arnaud Charlet

[multiple changes]

2015-11-25  Bob Duff  <duff@adacore.com>

	* sem_elab.adb (Check_Internal_Call_Continue): Code clean ups.

2015-11-25  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_util.ads (Has_Compatible_Alignment): Add Layout_Done
	parameter.
	* sem_util.adb (Has_Compatible_Alignment): Likewise.
	(Has_Compatible_Alignment_Internal): Likewise.	Do not set the
	result to Unknown for packed types if Layout_Done is true.
	* checks.adb (Apply_Address_Clause_Check): Adjust call and
	pass False to Has_Compatible_Alignment.
	* sem_ch13.adb (Validate_Address_Clauses): Likewise but pass True.

From-SVN: r230877
parent 3429710e
2015-11-25 Bob Duff <duff@adacore.com>
* sem_elab.adb (Check_Internal_Call_Continue): Code clean ups.
2015-11-25 Eric Botcazou <ebotcazou@adacore.com>
* sem_util.ads (Has_Compatible_Alignment): Add Layout_Done
parameter.
* sem_util.adb (Has_Compatible_Alignment): Likewise.
(Has_Compatible_Alignment_Internal): Likewise. Do not set the
result to Unknown for packed types if Layout_Done is true.
* checks.adb (Apply_Address_Clause_Check): Adjust call and
pass False to Has_Compatible_Alignment.
* sem_ch13.adb (Validate_Address_Clauses): Likewise but pass True.
2015-11-25 Vincent Celier <celier@adacore.com> 2015-11-25 Vincent Celier <celier@adacore.com>
* gnatcmd.adb: When <target>-gnat is called with switch -P * gnatcmd.adb: When <target>-gnat is called with switch -P
......
...@@ -749,14 +749,15 @@ package body Checks is ...@@ -749,14 +749,15 @@ package body Checks is
end if; end if;
end; end;
-- If the expression has the form X'Address, then we can find out if -- If the expression has the form X'Address, then we can find out if the
-- the object X has an alignment that is compatible with the object E. -- object X has an alignment that is compatible with the object E. If it
-- If it hasn't or we don't know, we defer issuing the warning until -- hasn't or we don't know, we defer issuing the warning until the end
-- the end of the compilation to take into account back end annotations. -- of the compilation to take into account back end annotations.
elsif Nkind (Expr) = N_Attribute_Reference elsif Nkind (Expr) = N_Attribute_Reference
and then Attribute_Name (Expr) = Name_Address and then Attribute_Name (Expr) = Name_Address
and then Has_Compatible_Alignment (E, Prefix (Expr)) = Known_Compatible and then
Has_Compatible_Alignment (E, Prefix (Expr), False) = Known_Compatible
then then
return; return;
end if; end if;
......
...@@ -13097,16 +13097,15 @@ package body Sem_Ch13 is ...@@ -13097,16 +13097,15 @@ package body Sem_Ch13 is
and then X_Size > Uint_0 and then X_Size > Uint_0
and then X_Size > Y_Size and then X_Size > Y_Size
then then
Error_Msg_NE Error_Msg_NE ("??& overlays smaller object", ACCR.N, ACCR.X);
("??& overlays smaller object", ACCR.N, ACCR.X);
Error_Msg_N Error_Msg_N
("\??program execution may be erroneous", ACCR.N); ("\??program execution may be erroneous", ACCR.N);
Error_Msg_Uint_1 := X_Size; Error_Msg_Uint_1 := X_Size;
Error_Msg_NE Error_Msg_NE ("\??size of & is ^", ACCR.N, ACCR.X);
("\??size of & is ^", ACCR.N, ACCR.X);
Error_Msg_Uint_1 := Y_Size; Error_Msg_Uint_1 := Y_Size;
Error_Msg_NE Error_Msg_NE ("\??size of & is ^", ACCR.N, ACCR.Y);
("\??size of & is ^", ACCR.N, ACCR.Y);
-- Check for inadequate alignment, both of the base object -- Check for inadequate alignment, both of the base object
-- and of the offset, if any. We only do this check if the -- and of the offset, if any. We only do this check if the
...@@ -13119,29 +13118,29 @@ package body Sem_Ch13 is ...@@ -13119,29 +13118,29 @@ package body Sem_Ch13 is
elsif not Alignment_Checks_Suppressed (ACCR.Y) elsif not Alignment_Checks_Suppressed (ACCR.Y)
and then Y_Alignment /= Uint_0 and then Y_Alignment /= Uint_0
and then (Y_Alignment < X_Alignment
or else (ACCR.Off
and then
Nkind (Expr) = N_Attribute_Reference
and then and then
Attribute_Name (Expr) = Name_Address (Y_Alignment < X_Alignment
and then or else
Has_Compatible_Alignment (ACCR.Off
(ACCR.X, Prefix (Expr)) and then Nkind (Expr) = N_Attribute_Reference
/= Known_Compatible)) and then Attribute_Name (Expr) = Name_Address
and then Has_Compatible_Alignment
(ACCR.X, Prefix (Expr), True) /=
Known_Compatible))
then then
Error_Msg_NE Error_Msg_NE
("??specified address for& may be inconsistent " ("??specified address for& may be inconsistent with "
& "with alignment", ACCR.N, ACCR.X); & "alignment", ACCR.N, ACCR.X);
Error_Msg_N Error_Msg_N
("\??program execution may be erroneous (RM 13.3(27))", ("\??program execution may be erroneous (RM 13.3(27))",
ACCR.N); ACCR.N);
Error_Msg_Uint_1 := X_Alignment; Error_Msg_Uint_1 := X_Alignment;
Error_Msg_NE Error_Msg_NE ("\??alignment of & is ^", ACCR.N, ACCR.X);
("\??alignment of & is ^", ACCR.N, ACCR.X);
Error_Msg_Uint_1 := Y_Alignment; Error_Msg_Uint_1 := Y_Alignment;
Error_Msg_NE Error_Msg_NE ("\??alignment of & is ^", ACCR.N, ACCR.Y);
("\??alignment of & is ^", ACCR.N, ACCR.Y);
if Y_Alignment >= X_Alignment then if Y_Alignment >= X_Alignment then
Error_Msg_N Error_Msg_N
("\??but offset is not multiple of alignment", ACCR.N); ("\??but offset is not multiple of alignment", ACCR.N);
......
...@@ -8369,11 +8369,13 @@ package body Sem_Util is ...@@ -8369,11 +8369,13 @@ package body Sem_Util is
function Has_Compatible_Alignment function Has_Compatible_Alignment
(Obj : Entity_Id; (Obj : Entity_Id;
Expr : Node_Id) return Alignment_Result Expr : Node_Id;
Layout_Done : Boolean) return Alignment_Result
is is
function Has_Compatible_Alignment_Internal function Has_Compatible_Alignment_Internal
(Obj : Entity_Id; (Obj : Entity_Id;
Expr : Node_Id; Expr : Node_Id;
Layout_Done : Boolean;
Default : Alignment_Result) return Alignment_Result; Default : Alignment_Result) return Alignment_Result;
-- This is the internal recursive function that actually does the work. -- This is the internal recursive function that actually does the work.
-- There is one additional parameter, which says what the result should -- There is one additional parameter, which says what the result should
...@@ -8389,6 +8391,7 @@ package body Sem_Util is ...@@ -8389,6 +8391,7 @@ package body Sem_Util is
function Has_Compatible_Alignment_Internal function Has_Compatible_Alignment_Internal
(Obj : Entity_Id; (Obj : Entity_Id;
Expr : Node_Id; Expr : Node_Id;
Layout_Done : Boolean;
Default : Alignment_Result) return Alignment_Result Default : Alignment_Result) return Alignment_Result
is is
Result : Alignment_Result := Known_Compatible; Result : Alignment_Result := Known_Compatible;
...@@ -8439,14 +8442,14 @@ package body Sem_Util is ...@@ -8439,14 +8442,14 @@ package body Sem_Util is
then then
Set_Result Set_Result
(Has_Compatible_Alignment_Internal (Has_Compatible_Alignment_Internal
(Obj, Prefix (Expr), Known_Compatible)); (Obj, Prefix (Expr), Layout_Done, Known_Compatible));
-- In all other cases, we need a full check on the prefix -- In all other cases, we need a full check on the prefix
else else
Set_Result Set_Result
(Has_Compatible_Alignment_Internal (Has_Compatible_Alignment_Internal
(Obj, Prefix (Expr), Unknown)); (Obj, Prefix (Expr), Layout_Done, Unknown));
end if; end if;
end Check_Prefix; end Check_Prefix;
...@@ -8465,14 +8468,14 @@ package body Sem_Util is ...@@ -8465,14 +8468,14 @@ package body Sem_Util is
begin begin
-- If Expr is a selected component, we must make sure there is no -- If Expr is a selected component, we must make sure there is no
-- potentially troublesome component clause, and that the record is -- potentially troublesome component clause and that the record is
-- not packed. -- not packed if the layout is not done.
if Nkind (Expr) = N_Selected_Component then if Nkind (Expr) = N_Selected_Component then
-- Packed record always generate unknown alignment -- Packing generates unknown alignment if layout is not done
if Is_Packed (Etype (Prefix (Expr))) then if Is_Packed (Etype (Prefix (Expr))) and then not Layout_Done then
Set_Result (Unknown); Set_Result (Unknown);
end if; end if;
...@@ -8483,7 +8486,7 @@ package body Sem_Util is ...@@ -8483,7 +8486,7 @@ package body Sem_Util is
-- If Expr is an indexed component, we must make sure there is no -- If Expr is an indexed component, we must make sure there is no
-- potentially troublesome Component_Size clause and that the array -- potentially troublesome Component_Size clause and that the array
-- is not bit-packed. -- is not bit-packed if the layout is not done.
elsif Nkind (Expr) = N_Indexed_Component then elsif Nkind (Expr) = N_Indexed_Component then
declare declare
...@@ -8491,9 +8494,9 @@ package body Sem_Util is ...@@ -8491,9 +8494,9 @@ package body Sem_Util is
Ind : constant Node_Id := First_Index (Typ); Ind : constant Node_Id := First_Index (Typ);
begin begin
-- Bit packed array always generates unknown alignment -- Packing generates unknown alignment if layout is not done
if Is_Bit_Packed_Array (Typ) then if Is_Bit_Packed_Array (Typ) and then not Layout_Done then
Set_Result (Unknown); Set_Result (Unknown);
end if; end if;
...@@ -8695,7 +8698,8 @@ package body Sem_Util is ...@@ -8695,7 +8698,8 @@ package body Sem_Util is
-- Now do the internal call that does all the work -- Now do the internal call that does all the work
return Has_Compatible_Alignment_Internal (Obj, Expr, Unknown); return
Has_Compatible_Alignment_Internal (Obj, Expr, Layout_Done, Unknown);
end Has_Compatible_Alignment; end Has_Compatible_Alignment;
---------------------- ----------------------
......
...@@ -992,16 +992,20 @@ package Sem_Util is ...@@ -992,16 +992,20 @@ package Sem_Util is
function Has_Compatible_Alignment function Has_Compatible_Alignment
(Obj : Entity_Id; (Obj : Entity_Id;
Expr : Node_Id) return Alignment_Result; Expr : Node_Id;
Layout_Done : Boolean) return Alignment_Result;
-- Obj is an object entity, and expr is a node for an object reference. If -- Obj is an object entity, and expr is a node for an object reference. If
-- the alignment of the object referenced by Expr is known to be compatible -- the alignment of the object referenced by Expr is known to be compatible
-- with the alignment of Obj (i.e. is larger or the same), then the result -- with the alignment of Obj (i.e. is larger or the same), then the result
-- is Known_Compatible. If the alignment of the object referenced by Expr -- is Known_Compatible. If the alignment of the object referenced by Expr
-- is known to be less than the alignment of Obj, then Known_Incompatible -- is known to be less than the alignment of Obj, then Known_Incompatible
-- is returned. If neither condition can be reliably established at compile -- is returned. If neither condition can be reliably established at compile
-- time, then Unknown is returned. This is used to determine if alignment -- time, then Unknown is returned. If Layout_Done is True, the function can
-- checks are required for address clauses, and also whether copies must -- assume that the information on size and alignment of types and objects
-- be made when objects are passed by reference. -- is present in the tree. This is used to determine if alignment checks
-- are required for address clauses (Layout_Done is False in this case) as
-- well as to issue appropriate warnings for them in the post compilation
-- phase (Layout_Done is True in this case).
-- --
-- Note: Known_Incompatible does not mean that at run time the alignment -- Note: Known_Incompatible does not mean that at run time the alignment
-- of Expr is known to be wrong for Obj, just that it can be determined -- of Expr is known to be wrong for Obj, just that it can be determined
......
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