return Expr_Value_R (Expr) = Ureal_0;
end if;
- -- For other types, we can look into the value as an integer
+ -- For other types, we can look into the value as an integer, which
+ -- means the representation value for enumeration literals.
- Value := Expr_Value (Expr);
+ Value := Expr_Rep_Value (Expr);
if Has_Biased_Representation (Ctyp) then
Value := Value - Expr_Value (Type_Low_Bound (Ctyp));
pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N))));
return Corresponding_Integer_Value (N);
- -- Otherwise must be character literal
+ -- The NULL access value
- else
- pragma Assert (Kind = N_Character_Literal);
+ elsif Kind = N_Null then
+ pragma Assert (Is_Access_Type (Underlying_Type (Etype (N)))
+ or else Error_Posted (N));
+ return Uint_0;
+
+ -- Character literal
+
+ elsif Kind = N_Character_Literal then
Ent := Entity (N);
-- Since Character literals of type Standard.Character don't have any
else
return Enumeration_Rep (Ent);
end if;
+
+ -- Unchecked conversion, which can come from System'To_Address (X)
+ -- where X is a static integer expression. Recursively evaluate X.
+
+ elsif Kind = N_Unchecked_Type_Conversion then
+ return Expr_Rep_Value (Expression (N));
+
+ else
+ raise Program_Error;
end if;
end Expr_Rep_Value;
-- or character literals. In the latter two cases, the value returned is
-- the Pos value in the relevant enumeration type. It can also be used for
-- fixed-point values, in which case it returns the corresponding integer
- -- value. It cannot be used for floating-point values.
+ -- value, but it cannot be used for floating-point values. Finally, it can
+ -- also be used for the Null access value, as well as for the result of an
+ -- unchecked conversion of the aforementioned handled values.
function Expr_Value_E (N : Node_Id) return Entity_Id;
-- Returns the folded value of the expression. This function is called in