public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Default initialize entity to avoid CodePeer message
@ 2023-05-26  7:36 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-26  7:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Yannick Moy

From: Yannick Moy <moy@adacore.com>

CodePeer issues a false alarm when reading local entity Component later
if not initialized by default. Fix this.

gcc/ada/

	* sem_aggr.adb (Resolve_Record_Aggregate): Add dummy initialization and
	assertion that clarifies when we reassigned to a useful value.

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

---
 gcc/ada/sem_aggr.adb | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 858ae635fc2..fd0779e66d7 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -6004,6 +6004,7 @@ package body Sem_Aggr is
             end if;
 
             while Present (Selectr) loop
+               Component := Empty;
                New_Assoc := First (New_Assoc_List);
                while Present (New_Assoc) loop
                   Component := First (Choices (New_Assoc));
@@ -6019,6 +6020,11 @@ package body Sem_Aggr is
                   Next (New_Assoc);
                end loop;
 
+               --  If we found an association, then this is a legal component
+               --  of the type in question.
+
+               pragma Assert (if Present (New_Assoc) then Present (Component));
+
                --  If no association, this is not a legal component of the type
                --  in question, unless its association is provided with a box.
 
-- 
2.40.0


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

only message in thread, other threads:[~2023-05-26  7:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26  7:36 [COMMITTED] ada: Default initialize entity to avoid CodePeer message 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).