From 66b69678563a18c87985456c797b397676094ff0 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Thu, 16 Jul 2020 12:38:10 -0400 Subject: [Ada] New warning on not fully initialized box aggregate gcc/ada/ * sem_aggr.adb (Resolve_Aggregate): Warn on not fully initialized box aggregate. * sem_aggr.ads: Fix typo. * sem_res.adb (Resolve_Actuals): Fix typo in error message format marking it incorrectly as a continuation message. * sem_elab.adb (Check_Internal_Call_Continue): Similarly, add missing primary message in case of a call to an actual generic subprogram. * sem_warn.adb (Check_References): Do not warn on read but never assigned variables if the type is partially initialized. * libgnat/a-except.ads, libgnat/a-ststun.ads, libgnat/g-sechas.ads, libgnat/a-cbdlli.ads, libgnat/a-cfdlli.ads, libgnat/a-cobove.ads, libgnat/a-cohata.ads, libgnat/a-crbltr.ads, libgnat/a-cbmutr.ads, libgnat/a-crdlli.ads, libgnat/a-cbsyqu.ads: Address new warning. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update doc on -gnatwv. * gnat_ugn.texi: Regenerate. gcc/testsuite/ * gnat.dg/opt11.adb: Add new expected warning. --- gcc/ada/libgnat/a-cbdlli.ads | 2 +- gcc/ada/libgnat/a-cbmutr.ads | 4 ++-- gcc/ada/libgnat/a-cbsyqu.ads | 2 +- gcc/ada/libgnat/a-cfdlli.ads | 2 +- gcc/ada/libgnat/a-cobove.ads | 2 +- gcc/ada/libgnat/a-cohata.ads | 2 +- gcc/ada/libgnat/a-crbltr.ads | 6 ++---- gcc/ada/libgnat/a-crdlli.ads | 2 +- gcc/ada/libgnat/a-except.ads | 2 ++ gcc/ada/libgnat/a-ststun.ads | 2 +- gcc/ada/libgnat/g-sechas.ads | 2 ++ 11 files changed, 15 insertions(+), 13 deletions(-) (limited to 'gcc/ada/libgnat') diff --git a/gcc/ada/libgnat/a-cbdlli.ads b/gcc/ada/libgnat/a-cbdlli.ads index 7f16368..7e8627a 100644 --- a/gcc/ada/libgnat/a-cbdlli.ads +++ b/gcc/ada/libgnat/a-cbdlli.ads @@ -274,7 +274,7 @@ private type Node_Array is array (Count_Type range <>) of Node_Type; type List (Capacity : Count_Type) is tagged record - Nodes : Node_Array (1 .. Capacity) := (others => <>); + Nodes : Node_Array (1 .. Capacity); Free : Count_Type'Base := -1; First : Count_Type := 0; Last : Count_Type := 0; diff --git a/gcc/ada/libgnat/a-cbmutr.ads b/gcc/ada/libgnat/a-cbmutr.ads index 82b3d60..a9fb55a 100644 --- a/gcc/ada/libgnat/a-cbmutr.ads +++ b/gcc/ada/libgnat/a-cbmutr.ads @@ -303,8 +303,8 @@ private type Element_Array is array (Count_Type range <>) of aliased Element_Type; type Tree (Capacity : Count_Type) is tagged record - Nodes : Tree_Node_Array (0 .. Capacity) := (others => <>); - Elements : Element_Array (1 .. Capacity) := (others => <>); + Nodes : Tree_Node_Array (0 .. Capacity); + Elements : Element_Array (1 .. Capacity); Free : Count_Type'Base := No_Node; TC : aliased Tamper_Counts; Count : Count_Type := 0; diff --git a/gcc/ada/libgnat/a-cbsyqu.ads b/gcc/ada/libgnat/a-cbsyqu.ads index 61504fa..225db21 100644 --- a/gcc/ada/libgnat/a-cbsyqu.ads +++ b/gcc/ada/libgnat/a-cbsyqu.ads @@ -78,7 +78,7 @@ is First, Last : Count_Type := 0; Length : Count_Type := 0; Max_Length : Count_Type := 0; - Elements : Element_Array (1 .. Capacity) := (others => <>); + Elements : Element_Array (1 .. Capacity); end record; end Implementation; diff --git a/gcc/ada/libgnat/a-cfdlli.ads b/gcc/ada/libgnat/a-cfdlli.ads index 6131239..f7dbf04 100644 --- a/gcc/ada/libgnat/a-cfdlli.ads +++ b/gcc/ada/libgnat/a-cfdlli.ads @@ -1617,7 +1617,7 @@ private Length : Count_Type := 0; First : Count_Type := 0; Last : Count_Type := 0; - Nodes : Node_Array (1 .. Capacity) := (others => <>); + Nodes : Node_Array (1 .. Capacity); end record; Empty_List : constant List := (0, others => <>); diff --git a/gcc/ada/libgnat/a-cobove.ads b/gcc/ada/libgnat/a-cobove.ads index 4c8905c..d0a1251 100644 --- a/gcc/ada/libgnat/a-cobove.ads +++ b/gcc/ada/libgnat/a-cobove.ads @@ -390,7 +390,7 @@ private function "=" (L, R : Elements_Array) return Boolean is abstract; type Vector (Capacity : Count_Type) is tagged record - Elements : Elements_Array (1 .. Capacity) := (others => <>); + Elements : Elements_Array (1 .. Capacity); Last : Extended_Index := No_Index; TC : aliased Tamper_Counts; end record with Put_Image => Put_Image; diff --git a/gcc/ada/libgnat/a-cohata.ads b/gcc/ada/libgnat/a-cohata.ads index 9033c52..2b98928 100644 --- a/gcc/ada/libgnat/a-cohata.ads +++ b/gcc/ada/libgnat/a-cohata.ads @@ -72,7 +72,7 @@ package Ada.Containers.Hash_Tables is Length : Count_Type := 0; TC : aliased Helpers.Tamper_Counts; Free : Count_Type'Base := -1; - Nodes : Nodes_Type (1 .. Capacity) := (others => <>); + Nodes : Nodes_Type (1 .. Capacity); Buckets : Buckets_Type (1 .. Modulus) := (others => 0); end record; diff --git a/gcc/ada/libgnat/a-crbltr.ads b/gcc/ada/libgnat/a-crbltr.ads index 0ae2abd..4f00bd6 100644 --- a/gcc/ada/libgnat/a-crbltr.ads +++ b/gcc/ada/libgnat/a-crbltr.ads @@ -60,9 +60,7 @@ package Ada.Containers.Red_Black_Trees is -- Note that objects of type Tree_Type are logically initialized (in the -- sense that representation invariants of type are satisfied by dint of -- default initialization), even without the Nodes component also having - -- its own initialization expression. We only initializae the Nodes - -- component here in order to prevent spurious compiler warnings about - -- the container object not being fully initialized. + -- its own initialization expression. type Tree_Type (Capacity : Count_Type) is tagged record First : Count_Type := 0; @@ -71,7 +69,7 @@ package Ada.Containers.Red_Black_Trees is Length : Count_Type := 0; TC : aliased Helpers.Tamper_Counts; Free : Count_Type'Base := -1; - Nodes : Nodes_Type (1 .. Capacity) := (others => <>); + Nodes : Nodes_Type (1 .. Capacity); end record; package Implementation is new Helpers.Generic_Implementation; diff --git a/gcc/ada/libgnat/a-crdlli.ads b/gcc/ada/libgnat/a-crdlli.ads index 7f27497..b30d353 100644 --- a/gcc/ada/libgnat/a-crdlli.ads +++ b/gcc/ada/libgnat/a-crdlli.ads @@ -314,7 +314,7 @@ private type Node_Array is array (Count_Type range <>) of Node_Type; type List (Capacity : Count_Type) is tagged limited record - Nodes : Node_Array (1 .. Capacity) := (others => <>); + Nodes : Node_Array (1 .. Capacity); Free : Count_Type'Base := -1; First : Count_Type := 0; Last : Count_Type := 0; diff --git a/gcc/ada/libgnat/a-except.ads b/gcc/ada/libgnat/a-except.ads index 22b7be9..4d36a84 100644 --- a/gcc/ada/libgnat/a-except.ads +++ b/gcc/ada/libgnat/a-except.ads @@ -301,6 +301,8 @@ private pragma Stream_Convert (Exception_Occurrence, String_To_EO, EO_To_String); -- Functions for implementing Exception_Occurrence stream attributes + pragma Warnings (Off, "aggregate not fully initialized"); Null_Occurrence : constant Exception_Occurrence := (others => <>); + pragma Warnings (On, "aggregate not fully initialized"); end Ada.Exceptions; diff --git a/gcc/ada/libgnat/a-ststun.ads b/gcc/ada/libgnat/a-ststun.ads index 95aca9b..2945bca 100644 --- a/gcc/ada/libgnat/a-ststun.ads +++ b/gcc/ada/libgnat/a-ststun.ads @@ -71,7 +71,7 @@ private EA : Stream_Element_Array (1 .. Last); end record; - Empty_Elements : aliased Elements_Type := (Last => 0, EA => (others => <>)); + Empty_Elements : aliased Elements_Type (0); type Elements_Access is access all Elements_Type; diff --git a/gcc/ada/libgnat/g-sechas.ads b/gcc/ada/libgnat/g-sechas.ads index 2edc2e3..566a696 100644 --- a/gcc/ada/libgnat/g-sechas.ads +++ b/gcc/ada/libgnat/g-sechas.ads @@ -218,7 +218,9 @@ package GNAT.Secure_Hashes is -- HMAC key end record; + pragma Warnings (Off, "aggregate not fully initialized"); Initial_Context : constant Context (KL => 0) := (others => <>); + pragma Warnings (On, "aggregate not fully initialized"); -- Initial values are provided by default initialization of Context type Hash_Stream (C : access Context) is -- cgit v1.1