]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove special-case for parentheses in expansion for GNATprove
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 13 Feb 2023 21:13:32 +0000 (22:13 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 23 May 2023 07:50:59 +0000 (09:50 +0200)
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.

gcc/ada/exp_ch4.adb

index f197c2ef570e94949461f4bbff11478f94f8d3fe..70e779d0406f13892d4fec2ec24e68b8fb2f45ba 100644 (file)
@@ -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;