public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Flip warning suppression routine to positive meaning
Date: Mon,  7 Nov 2022 09:40:34 +0100	[thread overview]
Message-ID: <20221107084034.151239-1-poulhies@adacore.com> (raw)

From: Piotr Trojanek <trojanek@adacore.com>

Subprogram names starting with No_ seem unnecessarily confusing.

Cleanup related to improved detection of references to uninitialized
objects; semantics is unaffected.

gcc/ada/

	* sem_warn.adb (Warn_On_In_Out): Remove No_ prefix; flip return
	values between True and False; adapt caller.

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

---
 gcc/ada/sem_warn.adb | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index a1a59a8857b..9dccf0d73d1 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -2971,7 +2971,7 @@ package body Sem_Warn is
 
    procedure Output_Non_Modified_In_Out_Warnings is
 
-      function No_Warn_On_In_Out (E : Entity_Id) return Boolean;
+      function Warn_On_In_Out (E : Entity_Id) return Boolean;
       --  Given a formal parameter entity E, determines if there is a reason to
       --  suppress IN OUT warnings (not modified, could be IN) for formals of
       --  the subprogram. We suppress these warnings if Warnings Off is set, or
@@ -2980,11 +2980,11 @@ package body Sem_Warn is
       --  context may force use of IN OUT, even if the parameter is not
       --  modified for this particular case).
 
-      -----------------------
-      -- No_Warn_On_In_Out --
-      -----------------------
+      --------------------
+      -- Warn_On_In_Out --
+      --------------------
 
-      function No_Warn_On_In_Out (E : Entity_Id) return Boolean is
+      function Warn_On_In_Out (E : Entity_Id) return Boolean is
          S  : constant Entity_Id := Scope (E);
          SE : constant Entity_Id := Spec_Entity (E);
 
@@ -2995,7 +2995,7 @@ package body Sem_Warn is
          if Address_Taken (S)
            or else (Present (SE) and then Address_Taken (Scope (SE)))
          then
-            return True;
+            return False;
 
          --  Do not warn if used as a generic actual, since the generic may be
          --  what is forcing the use of an "unnecessary" IN OUT.
@@ -3003,19 +3003,19 @@ package body Sem_Warn is
          elsif Used_As_Generic_Actual (S)
            or else (Present (SE) and then Used_As_Generic_Actual (Scope (SE)))
          then
-            return True;
+            return False;
 
          --  Else test warnings off on the subprogram
 
          elsif Warnings_Off (S) then
-            return True;
+            return False;
 
          --  All tests for suppressing warning failed
 
          else
-            return False;
+            return True;
          end if;
-      end No_Warn_On_In_Out;
+      end Warn_On_In_Out;
 
    --  Start of processing for Output_Non_Modified_In_Out_Warnings
 
@@ -3030,12 +3030,7 @@ package body Sem_Warn is
             --  Suppress warning in specific cases (see details in comments for
             --  No_Warn_On_In_Out).
 
-            if No_Warn_On_In_Out (E1) then
-               null;
-
-            --  Here we generate the warning
-
-            else
+            if Warn_On_In_Out (E1) then
                --  If -gnatwk is set then output message that it could be IN
 
                if not Is_Trivial_Subprogram (Scope (E1)) then
-- 
2.34.1


                 reply	other threads:[~2022-11-07  8:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221107084034.151239-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).