[gcc r11-1155] [Ada] Simplify detection of static membership choices

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Jun 10 13:36:14 GMT 2020


https://gcc.gnu.org/g:3ea95664954775a1a85c9ea097877754984807aa

commit r11-1155-g3ea95664954775a1a85c9ea097877754984807aa
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Thu Feb 20 12:10:53 2020 +0100

    [Ada] Simplify detection of static membership choices
    
    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.

Diff:
---
 gcc/ada/sem_ch13.adb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index fda31776eb0..61f5e45bb57 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/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;
 
    ------------------------


More information about the Gcc-cvs mailing list