Commit de4bf6cb by Geert Bosch Committed by Geert Bosch

ali-util.adb (Initialize_Checksum): Use out-mode instead of in out.

	* ali-util.adb (Initialize_Checksum): Use out-mode instead of in out.
	Found due to GCC 3.0 warning of using uninitialized value.

	* layout.adb:
	(Get_Max_Size): Use variant record for tracking value/expression.
	 Makes logic clearer and prevents warnings for uninitialized variables.
	(Layout_Array_Type): Use variant record for tracking value/expression.
	 Makes logic clearer and prevents warnings for uninitialized variables.

From-SVN: r46652
parent f5e44987
2001-10-30 Geert Bosch <bosch@gnat.com>
* ali-util.adb (Initialize_Checksum): Use out-mode instead of in out.
Found due to GCC 3.0 warning of using uninitialized value.
* layout.adb:
(Get_Max_Size): Use variant record for tracking value/expression.
Makes logic clearer and prevents warnings for uninitialized variables.
(Layout_Array_Type): Use variant record for tracking value/expression.
Makes logic clearer and prevents warnings for uninitialized variables.
2001-10-30 Robert Dewar <dewar@gnat.com> 2001-10-30 Robert Dewar <dewar@gnat.com>
* lib.adb: Minor reformatting * lib.adb: Minor reformatting
......
...@@ -50,7 +50,7 @@ package body ALI.Util is ...@@ -50,7 +50,7 @@ package body ALI.Util is
-- generate code, so it is not necessary to worry about making the right -- generate code, so it is not necessary to worry about making the right
-- sequence of calls in any error situation. -- sequence of calls in any error situation.
procedure Initialize_Checksum (Csum : in out Word); procedure Initialize_Checksum (Csum : out Word);
-- Sets initial value of Csum before any calls to Accumulate_Checksum -- Sets initial value of Csum before any calls to Accumulate_Checksum
------------------------- -------------------------
...@@ -286,7 +286,7 @@ package body ALI.Util is ...@@ -286,7 +286,7 @@ package body ALI.Util is
-- Initialize_Checksum -- -- Initialize_Checksum --
------------------------- -------------------------
procedure Initialize_Checksum (Csum : in out Word) is procedure Initialize_Checksum (Csum : out Word) is
begin begin
System.CRC32.Initialize (System.CRC32.CRC32 (Csum)); System.CRC32.Initialize (System.CRC32.CRC32 (Csum));
end Initialize_Checksum; end Initialize_Checksum;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- $Revision: 1.1 $ -- $Revision$
-- -- -- --
-- Copyright (C) 2001 Free Software Foundation, Inc. -- -- Copyright (C) 2001 Free Software Foundation, Inc. --
-- -- -- --
...@@ -579,20 +579,22 @@ package body Layout is ...@@ -579,20 +579,22 @@ package body Layout is
Len : Node_Id; Len : Node_Id;
type Val_Status_Type is (Const, Dynamic); type Val_Status_Type is (Const, Dynamic);
type Val_Type (Status : Val_Status_Type := Const) is
record
case Status is
when Const => Val : Uint;
when Dynamic => Nod : Node_Id;
end case;
end record;
-- Shows the status of the value so far. Const means that the value -- Shows the status of the value so far. Const means that the value
-- is constant, and Sval is the current constant value. Dynamic means -- is constant, and Val is the current constant value. Dynamic means
-- that the value is dynamic, and in this case Snod is the Node_Id of -- that the value is dynamic, and in this case Nod is the Node_Id of
-- the expression to compute the value. -- the expression to compute the value.
Val_Status : Val_Status_Type; Size : Val_Type;
-- Indicate status of value so far -- Calculated value so far if Size.Status = Const,
-- or expression value so far if Size.Status = Dynamic.
Sval : Uint := Uint_0;
-- Calculated value so far if Val_Status = Const
-- (initialized to prevent junk warning)
Snod : Node_Id;
-- Expression value so far if Val_Status = Dynamic
SU_Convert_Required : Boolean := False; SU_Convert_Required : Boolean := False;
-- This is set to True if the final result must be converted from -- This is set to True if the final result must be converted from
...@@ -644,12 +646,10 @@ package body Layout is ...@@ -644,12 +646,10 @@ package body Layout is
-- Initialize status from component size -- Initialize status from component size
if Known_Static_Component_Size (E) then if Known_Static_Component_Size (E) then
Val_Status := Const; Size := (Const, Component_Size (E));
Sval := Component_Size (E);
else else
Val_Status := Dynamic; Size := (Dynamic, Expr_From_SO_Ref (Loc, Component_Size (E)));
Snod := Expr_From_SO_Ref (Loc, Component_Size (E));
end if; end if;
-- Loop through indices -- Loop through indices
...@@ -678,8 +678,8 @@ package body Layout is ...@@ -678,8 +678,8 @@ package body Layout is
-- Current value is constant, evolve value -- Current value is constant, evolve value
if Val_Status = Const then if Size.Status = Const then
Sval := Sval * S; Size.Val := Size.Val * S;
-- Current value is dynamic -- Current value is dynamic
...@@ -695,9 +695,9 @@ package body Layout is ...@@ -695,9 +695,9 @@ package body Layout is
SU_Convert_Required := False; SU_Convert_Required := False;
end if; end if;
Snod := Size.Nod :=
Assoc_Multiply (Loc, Assoc_Multiply (Loc,
Left_Opnd => Snod, Left_Opnd => Size.Nod,
Right_Opnd => Right_Opnd =>
Make_Integer_Literal (Loc, Intval => S)); Make_Integer_Literal (Loc, Intval => S));
end if; end if;
...@@ -712,16 +712,17 @@ package body Layout is ...@@ -712,16 +712,17 @@ package body Layout is
-- we want to do the SU conversion after computing the size in -- we want to do the SU conversion after computing the size in
-- this case. -- this case.
if Val_Status = Const then if Size.Status = Const then
Val_Status := Dynamic;
-- If the current value is a multiple of the storage unit, -- If the current value is a multiple of the storage unit,
-- then most certainly we can do the conversion now, simply -- then most certainly we can do the conversion now, simply
-- by dividing the current value by the storage unit value. -- by dividing the current value by the storage unit value.
-- If this works, we set SU_Convert_Required to False. -- If this works, we set SU_Convert_Required to False.
if Sval mod SSU = 0 then if Size.Val mod SSU = 0 then
Snod := Make_Integer_Literal (Loc, Sval / SSU);
Size :=
(Dynamic, Make_Integer_Literal (Loc, Size.Val / SSU));
SU_Convert_Required := False; SU_Convert_Required := False;
-- Otherwise, we go ahead and convert the value in bits, -- Otherwise, we go ahead and convert the value in bits,
...@@ -729,7 +730,7 @@ package body Layout is ...@@ -729,7 +730,7 @@ package body Layout is
-- final value is indeed properly converted. -- final value is indeed properly converted.
else else
Snod := Make_Integer_Literal (Loc, Sval); Size := (Dynamic, Make_Integer_Literal (Loc, Size.Val));
SU_Convert_Required := True; SU_Convert_Required := True;
end if; end if;
end if; end if;
...@@ -771,8 +772,8 @@ package body Layout is ...@@ -771,8 +772,8 @@ package body Layout is
-- Here after processing all bounds to set sizes. If the value is -- Here after processing all bounds to set sizes. If the value is
-- a constant, then it is bits, and we just return the value. -- a constant, then it is bits, and we just return the value.
if Val_Status = Const then if Size.Status = Const then
return Make_Integer_Literal (Loc, Sval); return Make_Integer_Literal (Loc, Size.Val);
-- Case where the value is dynamic -- Case where the value is dynamic
...@@ -781,18 +782,18 @@ package body Layout is ...@@ -781,18 +782,18 @@ package body Layout is
if SU_Convert_Required then if SU_Convert_Required then
-- The expression required is (Snod + SU - 1) / SU -- The expression required is (Size.Nod + SU - 1) / SU
Snod := Size.Nod :=
Make_Op_Divide (Loc, Make_Op_Divide (Loc,
Left_Opnd => Left_Opnd =>
Make_Op_Add (Loc, Make_Op_Add (Loc,
Left_Opnd => Snod, Left_Opnd => Size.Nod,
Right_Opnd => Make_Integer_Literal (Loc, SSU - 1)), Right_Opnd => Make_Integer_Literal (Loc, SSU - 1)),
Right_Opnd => Make_Integer_Literal (Loc, SSU)); Right_Opnd => Make_Integer_Literal (Loc, SSU));
end if; end if;
return Snod; return Size.Nod;
end if; end if;
end Get_Max_Size; end Get_Max_Size;
...@@ -838,33 +839,40 @@ package body Layout is ...@@ -838,33 +839,40 @@ package body Layout is
-- question, and whose body is the expression. -- question, and whose body is the expression.
type Val_Status_Type is (Const, Dynamic, Discrim); type Val_Status_Type is (Const, Dynamic, Discrim);
-- Shows the status of the value so far. Const means that the value
-- is constant, and Sval is the current constant value. Dynamic means
-- that the value is dynamic, and in this case Snod is the Node_Id of
-- the expression to compute the value, and Discrim means that at least
-- one bound is a discriminant, in which case Snod is the expression so
-- far (which will be the body of the function).
Val_Status : Val_Status_Type; type Val_Type (Status : Val_Status_Type := Const) is
-- Indicate status of value so far record
case Status is
Sval : Uint := Uint_0; when Const =>
-- Calculated value so far if Val_Status = Const Val : Uint;
-- Initialized to prevent junk warning -- Calculated value so far if Val_Status = Const
Snod : Node_Id; when Dynamic | Discrim =>
-- Expression value so far if Val_Status /= Const Nod : Node_Id;
-- Expression value so far if Val_Status /= Const
Vtyp : Entity_Id;
-- Variant record type for the formal parameter of the discriminant end case;
-- function V if Val_Status = Discrim. end record;
-- Records the value or expression computed so far. Const means that
-- the value is constant, and Val is the current constant value.
-- Dynamic means that the value is dynamic, and in this case Nod is
-- the Node_Id of the expression to compute the value, and Discrim
-- means that at least one bound is a discriminant, in which case Nod
-- is the expression so far (which will be the body of the function).
Size : Val_Type;
-- Value of size computed so far. See comments above.
Vtyp : Entity_Id := Empty;
-- Variant record type for the formal parameter of the
-- discriminant function V if Status = Discrim.
SU_Convert_Required : Boolean := False; SU_Convert_Required : Boolean := False;
-- This is set to True if the final result must be converted from -- This is set to True if the final result must be converted from
-- bits to storage units (rounding up to a storage unit boundary). -- bits to storage units (rounding up to a storage unit boundary).
procedure Discrimify (N : in out Node_Id); procedure Discrimify (N : in out Node_Id);
-- If N represents a discriminant, then the Val_Status is set to -- If N represents a discriminant, then the Size.Status is set to
-- Discrim, and Vtyp is set. The parameter N is replaced with the -- Discrim, and Vtyp is set. The parameter N is replaced with the
-- proper expression to extract the discriminant value from V. -- proper expression to extract the discriminant value from V.
...@@ -882,9 +890,9 @@ package body Layout is ...@@ -882,9 +890,9 @@ package body Layout is
then then
Set_Size_Depends_On_Discriminant (E); Set_Size_Depends_On_Discriminant (E);
if Val_Status /= Discrim then if Size.Status /= Discrim then
Val_Status := Discrim;
Decl := Parent (Parent (Entity (N))); Decl := Parent (Parent (Entity (N)));
Size := (Discrim, Size.Nod);
Vtyp := Defining_Identifier (Decl); Vtyp := Defining_Identifier (Decl);
end if; end if;
...@@ -939,12 +947,10 @@ package body Layout is ...@@ -939,12 +947,10 @@ package body Layout is
-- Initialize status from component size -- Initialize status from component size
if Known_Static_Component_Size (E) then if Known_Static_Component_Size (E) then
Val_Status := Const; Size := (Const, Component_Size (E));
Sval := Component_Size (E);
else else
Val_Status := Dynamic; Size := (Dynamic, Expr_From_SO_Ref (Loc, Component_Size (E)));
Snod := Expr_From_SO_Ref (Loc, Component_Size (E));
end if; end if;
-- Loop to process array indices -- Loop to process array indices
...@@ -972,8 +978,8 @@ package body Layout is ...@@ -972,8 +978,8 @@ package body Layout is
-- If constant, evolve value -- If constant, evolve value
if Val_Status = Const then if Size.Status = Const then
Sval := Sval * S; Size.Val := Size.Val * S;
-- Current value is dynamic -- Current value is dynamic
...@@ -991,9 +997,9 @@ package body Layout is ...@@ -991,9 +997,9 @@ package body Layout is
-- Now go ahead and evolve the expression -- Now go ahead and evolve the expression
Snod := Size.Nod :=
Assoc_Multiply (Loc, Assoc_Multiply (Loc,
Left_Opnd => Snod, Left_Opnd => Size.Nod,
Right_Opnd => Right_Opnd =>
Make_Integer_Literal (Loc, Intval => S)); Make_Integer_Literal (Loc, Intval => S));
end if; end if;
...@@ -1008,16 +1014,16 @@ package body Layout is ...@@ -1008,16 +1014,16 @@ package body Layout is
-- we want to do the SU conversion after computing the size in -- we want to do the SU conversion after computing the size in
-- this case. -- this case.
if Val_Status = Const then if Size.Status = Const then
Val_Status := Dynamic;
-- If the current value is a multiple of the storage unit, -- If the current value is a multiple of the storage unit,
-- then most certainly we can do the conversion now, simply -- then most certainly we can do the conversion now, simply
-- by dividing the current value by the storage unit value. -- by dividing the current value by the storage unit value.
-- If this works, we set SU_Convert_Required to False. -- If this works, we set SU_Convert_Required to False.
if Sval mod SSU = 0 then if Size.Val mod SSU = 0 then
Snod := Make_Integer_Literal (Loc, Sval / SSU); Size :=
(Dynamic, Make_Integer_Literal (Loc, Size.Val / SSU));
SU_Convert_Required := False; SU_Convert_Required := False;
-- Otherwise, we go ahead and convert the value in bits, -- Otherwise, we go ahead and convert the value in bits,
...@@ -1025,7 +1031,7 @@ package body Layout is ...@@ -1025,7 +1031,7 @@ package body Layout is
-- final value is indeed properly converted. -- final value is indeed properly converted.
else else
Snod := Make_Integer_Literal (Loc, Sval); Size := (Dynamic, Make_Integer_Literal (Loc, Size.Val));
SU_Convert_Required := True; SU_Convert_Required := True;
end if; end if;
end if; end if;
...@@ -1073,9 +1079,9 @@ package body Layout is ...@@ -1073,9 +1079,9 @@ package body Layout is
-- At this stage, Len has the expression for the length -- At this stage, Len has the expression for the length
Snod := Size.Nod :=
Assoc_Multiply (Loc, Assoc_Multiply (Loc,
Left_Opnd => Snod, Left_Opnd => Size.Nod,
Right_Opnd => Len); Right_Opnd => Len);
end if; end if;
...@@ -1086,8 +1092,8 @@ package body Layout is ...@@ -1086,8 +1092,8 @@ package body Layout is
-- a constant, then it is bits, and the only thing we need to do -- a constant, then it is bits, and the only thing we need to do
-- is to check against explicit given size and do alignment adjust. -- is to check against explicit given size and do alignment adjust.
if Val_Status = Const then if Size.Status = Const then
Set_And_Check_Static_Size (E, Sval, Sval); Set_And_Check_Static_Size (E, Size.Val, Size.Val);
Adjust_Esize_Alignment (E); Adjust_Esize_Alignment (E);
-- Case where the value is dynamic -- Case where the value is dynamic
...@@ -1097,13 +1103,13 @@ package body Layout is ...@@ -1097,13 +1103,13 @@ package body Layout is
if SU_Convert_Required then if SU_Convert_Required then
-- The expression required is (Snod + SU - 1) / SU -- The expression required is (Size.Nod + SU - 1) / SU
Snod := Size.Nod :=
Make_Op_Divide (Loc, Make_Op_Divide (Loc,
Left_Opnd => Left_Opnd =>
Make_Op_Add (Loc, Make_Op_Add (Loc,
Left_Opnd => Snod, Left_Opnd => Size.Nod,
Right_Opnd => Make_Integer_Literal (Loc, SSU - 1)), Right_Opnd => Make_Integer_Literal (Loc, SSU - 1)),
Right_Opnd => Make_Integer_Literal (Loc, SSU)); Right_Opnd => Make_Integer_Literal (Loc, SSU));
end if; end if;
...@@ -1111,7 +1117,11 @@ package body Layout is ...@@ -1111,7 +1117,11 @@ package body Layout is
-- Now set the dynamic size (the Value_Size is always the same -- Now set the dynamic size (the Value_Size is always the same
-- as the Object_Size for arrays whose length is dynamic). -- as the Object_Size for arrays whose length is dynamic).
Set_Esize (E, SO_Ref_From_Expr (Snod, Insert_Typ, Vtyp)); -- ??? If Size.Status = Dynamic, Vtyp will not have been set.
-- The added initialization sets it to Empty now, but is this
-- correct?
Set_Esize (E, SO_Ref_From_Expr (Size.Nod, Insert_Typ, Vtyp));
Set_RM_Size (E, Esize (E)); Set_RM_Size (E, Esize (E));
end if; end if;
end Layout_Array_Type; end Layout_Array_Type;
......
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