https://gcc.gnu.org/g:f9d22b7ac734a917f3ee379336ad764ccd6f74ca

commit r15-6853-gf9d22b7ac734a917f3ee379336ad764ccd6f74ca
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Mon Jan 6 12:06:59 2025 +0100

    ada: Simplify expansion of negative membership operator
    
    Code cleanup; semantics is unaffected.
    
    gcc/ada/ChangeLog:
    
            * exp_ch4.adb: (Expand_N_Not_In): Preserve Alternatives in expanded
            membership operator just like preserving Right_Opnd (though only
            one of these fields is present at a time).
            * par-ch4.adb (P_Membership_Test): Remove redundant setting of 
fields
            to their default values.

Diff:
---
 gcc/ada/exp_ch4.adb | 9 +++------
 gcc/ada/par-ch4.adb | 4 +---
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index a7f759fc8a57..82978c775cf2 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -7727,12 +7727,9 @@ package body Exp_Ch4 is
         Make_Op_Not (Loc,
           Right_Opnd =>
             Make_In (Loc,
-              Left_Opnd  => Left_Opnd (N),
-              Right_Opnd => Right_Opnd (N))));
-
-      --  If this is a set membership, preserve list of alternatives
-
-      Set_Alternatives (Right_Opnd (N), Alternatives (Original_Node (N)));
+              Left_Opnd    => Left_Opnd (N),
+              Right_Opnd   => Right_Opnd (N),
+              Alternatives => Alternatives (N))));
 
       --  We want this to appear as coming from source if original does (see
       --  transformations in Expand_N_In).
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 3f8d1f1d2e34..648a4cf64641 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -3926,7 +3926,6 @@ package body Ch4 is
       if Token = Tok_Vertical_Bar then
          Error_Msg_Ada_2012_Feature ("set notation", Token_Ptr);
          Set_Alternatives (N, New_List (Alt));
-         Set_Right_Opnd   (N, Empty);
 
          --  Loop to accumulate alternatives
 
@@ -3940,8 +3939,7 @@ package body Ch4 is
       --  Not set case
 
       else
-         Set_Right_Opnd   (N, Alt);
-         Set_Alternatives (N, No_List);
+         Set_Right_Opnd (N, Alt);
       end if;
    end P_Membership_Test;

Reply via email to