procedure Fold_Uint (N : Node_Id; Val : Uint; Static : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
- Typ : Entity_Id := Etype (N);
- Ent : Entity_Id;
+
+ Actual_Typ : Entity_Id;
+ Ent : Entity_Id;
+ Typ : Entity_Id;
begin
if Raises_Constraint_Error (N) then
return;
end if;
+ Typ := Etype (N);
+
+ if Is_Private_Type (Typ) then
+ Typ := Full_View (Typ);
+ end if;
+
-- If we are folding a named number, retain the entity in the literal
-- in the original tree.
if Is_Entity_Name (N) and then Ekind (Entity (N)) = E_Named_Integer then
+ Actual_Typ := Universal_Integer;
Ent := Entity (N);
else
+ Actual_Typ := Typ;
Ent := Empty;
end if;
- if Is_Private_Type (Typ) then
- Typ := Full_View (Typ);
- end if;
-
-- For a result of type integer, substitute an N_Integer_Literal node
-- for the result of the compile time evaluation of the expression.
-- Set a link to the original named number when not in a generic context
Analyze (N);
Set_Is_Static_Expression (N, Static);
- Set_Etype (N, Typ);
- Resolve (N);
+ Set_Etype (N, Actual_Typ);
+ Resolve (N, Typ);
Set_Is_Static_Expression (N, Static);
end Fold_Uint;
procedure Fold_Ureal (N : Node_Id; Val : Ureal; Static : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
- Ent : Entity_Id;
+
+ Actual_Typ : Entity_Id;
+ Ent : Entity_Id;
begin
if Raises_Constraint_Error (N) then
-- in the original tree.
if Is_Entity_Name (N) and then Ekind (Entity (N)) = E_Named_Real then
+ Actual_Typ := Universal_Real;
Ent := Entity (N);
else
+ Actual_Typ := Typ;
Ent := Empty;
end if;
Analyze (N);
Set_Is_Static_Expression (N, Static);
- Set_Etype (N, Typ);
- Resolve (N);
+ Set_Etype (N, Actual_Typ);
+ Resolve (N, Typ);
Set_Analyzed (N);
Set_Is_Static_Expression (N, Static);
end Fold_Ureal;
if Den /= 1 then
- -- For a source program literal for a decimal fixed-point type,
- -- this is statically illegal (RM 4.9(36)).
+ -- This is illegal for the value of a static expression of type
+ -- universal_real if the expected type is a decimal fixed-point
+ -- type (RM 4.9(36/2)).
- if Is_Decimal_Fixed_Point_Type (Typ)
+ if Is_OK_Static_Expression (N)
and then Actual_Typ = Universal_Real
- and then Comes_From_Source (N)
+ and then Is_Decimal_Fixed_Point_Type (Typ)
then
Error_Msg_N ("value has extraneous low order digits", N);
end if;