-- Expand_Unchecked_Union_Equality --
-------------------------------------
- procedure Expand_Unchecked_Union_Equality
- (N : Node_Id;
- Eq : Entity_Id;
- Lhs : Node_Id;
- Rhs : Node_Id)
- is
+ procedure Expand_Unchecked_Union_Equality (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
+ Eq : constant Entity_Id := Entity (Name (N));
+ Lhs : constant Node_Id := First_Actual (N);
+ Rhs : constant Node_Id := Next_Actual (Lhs);
function Get_Discr_Values (Op : Node_Id; Lhs : Boolean) return Elist_Id;
-- Return the list of inferred discriminant values for Op
-- Start of processing for Expand_Unchecked_Union_Equality
begin
+ -- Guard against repeated invocation on the same node
+
+ if Present (Next_Actual (Rhs)) then
+ return;
+ end if;
+
-- If we can infer the discriminants of the operands, make a call to Eq
if Has_Inferable_Discriminants (Lhs)
-- membership test. The whole membership is rewritten connecting these
-- with OR ELSE.
- procedure Expand_Unchecked_Union_Equality
- (N : Node_Id;
- Eq : Entity_Id;
- Lhs : Node_Id;
- Rhs : Node_Id);
+ procedure Expand_Unchecked_Union_Equality (N : Node_Id);
-- Expand a call to the predefined equality operator of an unchecked union
- -- type, possibly rewriting as a raise statement.
+ -- type, possibly rewriting it as a raise statement.
function Integer_Promotion_Possible (N : Node_Id) return Boolean;
-- Returns true if the node is a type conversion whose operand is an
elsif Is_Unchecked_Union_Equality (N) then
declare
- Eq : constant Entity_Id := Entity (Name (N));
- Lhs : constant Node_Id := First_Actual (N);
- Rhs : constant Node_Id := Next_Actual (Lhs);
+ Eq : constant Entity_Id := Entity (Name (N));
begin
- Expand_Unchecked_Union_Equality (N, Eq, Lhs, Rhs);
+ Expand_Unchecked_Union_Equality (N);
-- If the call was not rewritten as a raise, expand the actuals