[COMMITTED] ada: Remove special-case for parentheses in expansion for GNATprove

Message ID 20230523080754.1873095-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Remove special-case for parentheses in expansion for GNATprove |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 23, 2023, 8:07 a.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

When expanding of inequality operators for GNAT we were adding extra
parens, supposedly to "fix Sprint output" (source print); for GNATprove
we didn't, as these extra parens were leading to wrong columns for check
messages.

Adding these extra parens couldn't be a right, because Sprint should
produce reasonable output regardless of the parens, especially since we
don't care about parens when creating AST in expansion. Avoiding them
for GNATprove couldn't be right either, because source printing should
work regardless of the GNAT/GNATprove mode.

The proper fix for GNAT is rather to not add parens at all and tune
source printing, if necessary. The proper fix for GNATprove is not have
them either, as it confuses the heuristic in First_Sloc, which is then
used by Compute_Sloc.

gcc/ada/

	* exp_ch4.adb (Expand_N_Op_Ne): Simply don't add extra parens.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch4.adb | 8 --------
 1 file changed, 8 deletions(-)
  

Patch

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index f197c2ef570..70e779d0406 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -10119,14 +10119,6 @@  package body Exp_Ch4 is
                     Left_Opnd  => Left_Opnd (N),
                     Right_Opnd => Right_Opnd (N)));
 
-            --  The level of parentheses is useless in GNATprove mode, and
-            --  bumping its level here leads to wrong columns being used in
-            --  check messages, hence skip it in this mode.
-
-            if not GNATprove_Mode then
-               Set_Paren_Count (Right_Opnd (Neg), 1);
-            end if;
-
             if Scope (Ne) /= Standard_Standard then
                Set_Entity (Right_Opnd (Neg), Corresponding_Equality (Ne));
             end if;