This patch fixes a bug where if you have a Predicate_Failure aspect on a
nested type, but no Predicate, Static_Predicate, or Dynamic_Predicate,
the compiler crashes when compiled with assertions enabled.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-11  Bob Duff  <d...@adacore.com>

gcc/ada/

        * sem_ch13.adb (Analyze_Aspect_Specifications): Do not set the
        Has_Predicates flag when the Predicate_Failure aspect is seen.
        It is legal (but pointless) to use this aspect without a
        predicate.  If we set the flag, we generate a half-baked
        Predicate procedure, and if that procedure is nested, it causes
        unnesting to crash.
--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -2540,8 +2540,6 @@ package body Sem_Ch13 is
                          Expression => Relocate_Node (Expr))),
                      Pragma_Name => Name_Predicate_Failure);
 
-                  Set_Has_Predicates (E);
-
                   --  If the type is private, indicate that its completion
                   --  has a freeze node, because that is the one that will
                   --  be visible at freeze time.

Reply via email to