public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-190] ada: Spurious reference warning on qualified expression
@ 2024-05-06  9:17 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2024-05-06  9:17 UTC (permalink / raw)
  To: gcc-cvs

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-06  9:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06  9:17 [gcc r15-190] ada: Spurious reference warning on qualified expression Marc Poulhi?s

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).