diff options
author | Ed Schonberg <schonberg@adacore.com> | 2020-12-23 20:21:13 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-03 05:28:22 -0400 |
commit | 3fcdd5264de355acf01d30b7af6edd614080f1d3 (patch) | |
tree | 67a01ce5e01070116727a44779419aac72a17d11 /gcc | |
parent | 3ffe57d4b11ca8daab277d94c86db2b95feafa9d (diff) | |
download | gcc-3fcdd5264de355acf01d30b7af6edd614080f1d3.zip gcc-3fcdd5264de355acf01d30b7af6edd614080f1d3.tar.gz gcc-3fcdd5264de355acf01d30b7af6edd614080f1d3.tar.bz2 |
[Ada] Spurious warning about premature use of selected component
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_warn.adb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index b5275a8..0be6b39 100644 --- 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 |