[Ada] Simplify detection of static membership choices
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 20 Feb 2020 11:10:53 +0000 (12:10 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 10 Jun 2020 13:34:57 +0000 (09:34 -0400)
2020-06-10  Piotr Trojanek  <trojanek@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

index fda31776eb0a18a791142b2bfbc836bb90fd9fff..61f5e45bb57aea65d72bf269ef6cf7f0dc1932e5 100644 (file)
@@ -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;
 
    ------------------------