===================================================================
@@ -1385,9 +1385,17 @@ package body Sem_Ch4 is
procedure Analyze_Conditional_Expression (N : Node_Id) is
Condition : constant Node_Id := First (Expressions (N));
Then_Expr : constant Node_Id := Next (Condition);
- Else_Expr : constant Node_Id := Next (Then_Expr);
+ Else_Expr : Node_Id;
begin
+ -- Defend against error of missing expressions from previous error
+
+ if No (Then_Expr) then
+ return;
+ end if;
+
+ Else_Expr := Next (Then_Expr);
+
if Comes_From_Source (N) then
Check_Compiler_Unit (N);
end if;
===================================================================
@@ -1251,14 +1251,20 @@ package body Sprint is
declare
Condition : constant Node_Id := First (Expressions (Node));
Then_Expr : constant Node_Id := Next (Condition);
- Else_Expr : constant Node_Id := Next (Then_Expr);
+
begin
Write_Str_With_Col_Check_Sloc ("(if ");
Sprint_Node (Condition);
Write_Str_With_Col_Check (" then ");
- Sprint_Node (Then_Expr);
- Write_Str_With_Col_Check (" else ");
- Sprint_Node (Else_Expr);
+
+ -- Defense against junk here!
+
+ if Present (Then_Expr) then
+ Sprint_Node (Then_Expr);
+ Write_Str_With_Col_Check (" else ");
+ Sprint_Node (Next (Then_Expr));
+ end if;
+
Write_Char (')');
end;