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

commit r16-4969-gbd03df4cac5af997df9668a533fa23b1c867d5d0
Author: Bob Duff <[email protected]>
Date:   Mon Oct 6 06:56:34 2025 -0400

    ada: Incorrect warning redundant parens on in
    
    This patch fixes a bug where GNAT gives a warning
    about redundant parentheses on expressions like "(X in S) = B".
    In fact, the parentheses are required in this case.
    
    The bug is caused by constant-folding the expression into
    an expression that does not require parentheses, but in
    a way that retains the parentheses. The fix is to look
    at Original_Node.
    
    gcc/ada/ChangeLog:
    
            * style.adb (Check_Xtra_Parens_Precedence):
            Give warning based on Original_Node.

Diff:
---
 gcc/ada/style.adb | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb
index 6e5688de706c..56d1060bd793 100644
--- a/gcc/ada/style.adb
+++ b/gcc/ada/style.adb
@@ -345,12 +345,14 @@ package body Style is
    begin
       if Style_Check_Xtra_Parens_Precedence
         and then
-          Paren_Count (N) >
-            (if Nkind (N) in N_Case_Expression
-                           | N_Expression_With_Actions
-                           | N_If_Expression
-                           | N_Quantified_Expression
-                           | N_Raise_Expression
+          Paren_Count (Original_Node (N)) >
+            (if Nkind (Original_Node (N)) in N_Case_Expression
+                                           | N_Expression_With_Actions
+                                           | N_If_Expression
+                                           | N_Quantified_Expression
+                                           | N_Raise_Expression
+                                           | N_In
+                                           | N_Not_In
              then 1
              else 0)
       then

Reply via email to