Membership test operators (i.e. "in" and "not in") have either the right
operand present (when there is just one choice) or the list of
alternatives present (when there are many choices), as documented in
sinfo.ads.

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

2020-06-10  Piotr Trojanek  <troja...@adacore.com>

gcc/ada/

        * sem_ch13.adb (All_Membership_Choices_Static): Assert an AST
        property documented in sinfo.ads and simplify an excessive
        condition.
--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -844,11 +844,16 @@ package body Sem_Ch13 is
    function All_Membership_Choices_Static (Expr : Node_Id) return Boolean is
       pragma Assert (Nkind (Expr) in N_Membership_Test);
    begin
-      return ((Present (Right_Opnd (Expr))
-              and then Is_Static_Choice (Right_Opnd (Expr)))
-            or else
-              (Present (Alternatives (Expr))
-              and then All_Static_Choices (Alternatives (Expr))));
+      pragma Assert
+        (Present (Right_Opnd (Expr))
+           xor
+         Present (Alternatives (Expr)));
+
+      if Present (Right_Opnd (Expr)) then
+         return Is_Static_Choice (Right_Opnd (Expr));
+      else
+         return All_Static_Choices (Alternatives (Expr));
+      end if;
    end All_Membership_Choices_Static;
 
    ------------------------

Reply via email to