[Ada] Avoid internal compiler error for illegal Predicate_Failure aspect spec
authorSteve Baird <baird@adacore.com>
Thu, 14 Apr 2022 20:24:15 +0000 (13:24 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:31 +0000 (14:05 +0000)
gcc/ada/

* sem_ch13.adb (Build_Predicate_Functions): If a semantic error
has been detected then ignore Predicate_Failure aspect
specifications in the same way as is done for CodePeer and
SPARK. This avoids an internal compiler error if
Ancestor_Predicate_Function_Called is True but Result_Expr is
not an N_And_Then node (and is therefore unsuitable as an
argument in a call to Left_Opnd).

gcc/ada/sem_ch13.adb

index c405d15..11abdd8 100644 (file)
@@ -10489,11 +10489,14 @@ package body Sem_Ch13 is
             begin
                --  In GNATprove mode we are only interested in the predicate
                --  expression itself and don't want a raise expression that
-               --  comes from the Predicate_Failure.
+               --  comes from the Predicate_Failure. Ditto for CodePeer.
+               --  And an illegal Predicate_Failure aspect can lead to cases
+               --  we want to avoid.
 
                if Present (PF_Expr)
                  and then not GNATprove_Mode
                  and then not CodePeer_Mode
+                 and then Serious_Errors_Detected = 0
                then
                   pragma Assert (Present (Second_Formal));