]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Improve recovery from illegal occurrence of 'Old in if_expression
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 22 Feb 2024 21:26:01 +0000 (22:26 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 16 May 2024 08:49:31 +0000 (10:49 +0200)
Fix assertion failure in developer builds which happened when the THEN
expression contains an illegal occurrence of 'Old and the type of the
THEN expression is left as Any_Type, but there is no ELSE expression.

gcc/ada/

* sem_ch4.adb (Analyze_If_Expression): Add guard for
if_expression without an ELSE part.

gcc/ada/sem_ch4.adb

index b4414a3f7ff9decf580a283721bacd72abfb5757..03364dade9f63c76c126531e415ec4f41198beb8 100644 (file)
@@ -2645,7 +2645,7 @@ package body Sem_Ch4 is
                  ("\ELSE expression has}!", Else_Expr, Etype (Else_Expr));
             end if;
 
-         else
+         elsif Present (Else_Expr) then
             if Is_Overloaded (Else_Expr) then
                Error_Msg_N
                  ("no interpretation compatible with type of THEN expression",