* [Ada] Spurious warning about premature use of selected component
@ 2021-05-03 9:29 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-03 9:29 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
Compiler emits a warning on a selected component that is an actual in a
function call, when the enclosing object has no explicit initialization
and no discriminants, but the component type itself has partial
initialization. Such a warning should be suppressed.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_warn.adb (Check_References): Do not emit warning on a
selected component when enclosing type has no discriminant and
type of component has partial initialization.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 947 bytes --]
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1523,6 +1523,17 @@ package body Sem_Warn is
-- uninitialized component to get a better message.
elsif Nkind (Parent (UR)) = N_Selected_Component then
+ -- Suppress possibly superfluous warning if component
+ -- is known to exist and is partially initialized.
+
+ if not Has_Discriminants (Etype (E1))
+ and then
+ Is_Partially_Initialized_Type
+ (Etype (Parent (UR)), False)
+ then
+ goto Continue;
+ end if;
+
Error_Msg_Node_2 := Selector_Name (Parent (UR));
if not Comes_From_Source (Parent (UR)) then
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-03 9:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 9:29 [Ada] Spurious warning about premature use of selected component Pierre-Marie de Rodat
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).