gcc/ada/
* exp_util.ads (Get_Current_Value_Condition): Belt: Add a
postcondition that Val /= Var.
* sem_util.adb (Known_Null): Suspenders: Raise Program_Error if
Get_Current_Value_Condition returned the same value. This will
be enabled even without assertions, because infinite recursion
is a nuisance -- better to crash if this bug ever occurs.
procedure Get_Current_Value_Condition
(Var : Node_Id;
Op : out Node_Kind;
- Val : out Node_Id);
+ Val : out Node_Id) with Post => Val /= Var;
-- This routine processes the Current_Value field of the variable Var. If
-- the Current_Value field is null or if it represents a known value, then
-- on return Cond is set to N_Empty, and Val is set to Empty.
Get_Current_Value_Condition (N, Op, Val);
+ -- If Get_Current_Value_Condition were to return Val = N, then the
+ -- recursion below could be infinite.
+
+ if Val = N then
+ raise Program_Error;
+ end if;
+
if Known_Null (Val) then
if Op = N_Op_Eq then
return True;