public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r15-190] ada: Spurious reference warning on qualified expression
Date: Mon,  6 May 2024 09:17:08 +0000 (GMT)	[thread overview]
Message-ID: <20240506091708.5F6B33858424@sourceware.org> (raw)

https://gcc.gnu.org/g:0b7c0811ced8c98b4bebd1bc89f2272216000900

commit r15-190-g0b7c0811ced8c98b4bebd1bc89f2272216000900
Author: Justin Squirek <squirek@adacore.com>
Date:   Thu Dec 21 18:31:27 2023 +0000

    ada: Spurious reference warning on qualified expression
    
    This patch fixes an error in the compiler whereby an assignment to an out
    formal (whose type requires a predicate check) can lead to spurious
    "value may be referenced before it has a value" warnings when the RHS is a
    qualified expression.
    
    gcc/ada/
    
            * sem_warn.adb (Within_Postcondition): Add case to ignore
            references within generated predicate function calls.

Diff:
---
 gcc/ada/sem_warn.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index eaf9a257ba0..0a54b3eda50 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1982,6 +1982,16 @@ package body Sem_Warn is
                            then
                               return True;
 
+                           --  Verify we are not within a generated predicate
+                           --  function call.
+
+                           elsif Nkind (Nod) = N_Function_Call
+                             and then Is_Entity_Name (Name (Nod))
+                             and then Is_Predicate_Function
+                                        (Entity (Name (Nod)))
+                           then
+                              return True;
+
                            elsif Present (Parent (Nod)) then
                               P := Parent (Nod);

                 reply	other threads:[~2024-05-06  9:17 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=20240506091708.5F6B33858424@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).