From patchwork Tue Sep 12 10:16:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 812753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461900-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ky98Aj8b"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xs10p1YWkz9s0Z for ; Tue, 12 Sep 2017 20:16:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=GFO5g+YgrD4PZgaJa8ntVM5jpydmSCGAVmpBnSyPxudo+Ep2rC +EWgTTWwiwy6e5opYVzYkQVZISzW5xqm/H/wjk+hO1TMzJcoD0xByh8Zy5HccKsg ZdRpWAn1JDAUOcP6ZjmyJDv5A+c1mhxHicVpIQXbE7ohn4D6Oj4vkIAvs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=/AhA0Y6CbYxr3qWbZCsN2YTBgZk=; b=ky98Aj8bTXMOtxyUry4e i3oHqjCr/yEl2P1Dvdz2s4nUcSb+nKJFunIAIP7M3SZ4g0Hp7D11glsrbIa3fCpk L+gEsXPuyQGM3LtMHR+hI4alSL/zSsvg1K4nEKAGziXqkBw+LC5HonL4YjWT0v3N LZVgqujjxbgs4WHk4zv7oik= Received: (qmail 16756 invoked by alias); 12 Sep 2017 10:16:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 16746 invoked by uid 89); 12 Sep 2017 10:16:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Sep 2017 10:16:11 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7B4B2560B9; Tue, 12 Sep 2017 06:16:09 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7AIcnfhIjZCG; Tue, 12 Sep 2017 06:16:09 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 6657856040; Tue, 12 Sep 2017 06:16:09 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 62D38521; Tue, 12 Sep 2017 06:16:09 -0400 (EDT) Date: Tue, 12 Sep 2017 06:16:09 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Spurious warning in Containers.Bounded_Doubly_Linked_Lists Message-ID: <20170912101609.GA9683@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes a bug in which an instantiation of Containers.Bounded_Doubly_Linked_Lists can give warnings if the actual type passed to Element_Type is not fully default-initialized. The following test should compile quietly. with Ada.Containers.Bounded_Doubly_Linked_Lists; procedure Test is type Async_Construct_Query_Info_T is record From_Index : Positive; To_Index : Positive; end record; package Async_Construct_Query_Info_Queue is new Ada.Containers.Bounded_Doubly_Linked_Lists (Async_Construct_Query_Info_T); begin null; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-12 Bob Duff * libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb, libgnat/a-cbmutr.adb, libgnat/a-cborma.adb: Rename New_Item to be Default_Initialized_Item, and apply pragma Unmodified to it, to suppress the warning. Index: libgnat/a-cbhama.adb =================================================================== --- libgnat/a-cbhama.adb (revision 251998) +++ libgnat/a-cbhama.adb (working copy) @@ -578,8 +578,9 @@ ----------------- procedure Assign_Key (Node : in out Node_Type) is - New_Item : Element_Type; - pragma Unmodified (New_Item); + pragma Warnings (Off); + Default_Initialized_Item : Element_Type; + pragma Unmodified (Default_Initialized_Item); -- Default-initialized element (ok to reference, see below) begin @@ -591,7 +592,8 @@ -- default initialization, so insert a possibly initialized element -- under the given key. - Node.Element := New_Item; + Node.Element := Default_Initialized_Item; + pragma Warnings (On); end Assign_Key; -------------- Index: libgnat/a-cborma.adb =================================================================== --- libgnat/a-cborma.adb (revision 251998) +++ libgnat/a-cborma.adb (working copy) @@ -851,8 +851,9 @@ ------------ procedure Assign (Node : in out Node_Type) is - New_Item : Element_Type; - pragma Unmodified (New_Item); + pragma Warnings (Off); + Default_Initialized_Item : Element_Type; + pragma Unmodified (Default_Initialized_Item); -- Default-initialized element (ok to reference, see below) begin @@ -863,7 +864,8 @@ -- with such a scalar component or with defaulted components, so insert -- possibly initialized elements at the given position. - Node.Element := New_Item; + Node.Element := Default_Initialized_Item; + pragma Warnings (On); end Assign; -------------- Index: libgnat/a-cbdlli.adb =================================================================== --- libgnat/a-cbdlli.adb (revision 251998) +++ libgnat/a-cbdlli.adb (working copy) @@ -1016,9 +1016,13 @@ Count : Count_Type := 1) is pragma Warnings (Off); - New_Item : Element_Type; + Default_Initialized_Item : Element_Type; + pragma Unmodified (Default_Initialized_Item); -- OK to reference, see below. Note that we need to suppress both the - -- front end warning and the back end warning. + -- front end warning and the back end warning. In addition, pragma + -- Unmodified is needed to suppress the warning ``actual type for + -- "Element_Type" should be fully initialized type'' on certain + -- instantiations. begin -- There is no explicit element provided, but in an instance the element @@ -1027,7 +1031,7 @@ -- initialization, so insert the specified number of possibly -- initialized elements at the given position. - Insert (Container, Before, New_Item, Position, Count); + Insert (Container, Before, Default_Initialized_Item, Position, Count); pragma Warnings (On); end Insert; Index: libgnat/a-cbmutr.adb =================================================================== --- libgnat/a-cbmutr.adb (revision 251998) +++ libgnat/a-cbmutr.adb (working copy) @@ -1581,8 +1581,9 @@ First : Count_Type; Last : Count_Type; - New_Item : Element_Type; - pragma Unmodified (New_Item); + pragma Warnings (Off); + Default_Initialized_Item : Element_Type; + pragma Unmodified (Default_Initialized_Item); -- OK to reference, see below begin @@ -1629,12 +1630,13 @@ -- initialization, so insert the specified number of possibly -- initialized elements at the given position. - Allocate_Node (Container, New_Item, First); + Allocate_Node (Container, Default_Initialized_Item, First); Nodes (First).Parent := Parent.Node; Last := First; for J in Count_Type'(2) .. Count loop - Allocate_Node (Container, New_Item, Nodes (Last).Next); + Allocate_Node + (Container, Default_Initialized_Item, Nodes (Last).Next); Nodes (Nodes (Last).Next).Parent := Parent.Node; Nodes (Nodes (Last).Next).Prev := Last; @@ -1651,6 +1653,7 @@ Container.Count := Container.Count + Count; Position := Cursor'(Parent.Container, First); + pragma Warnings (On); end Insert_Child; -------------------------