From patchwork Tue Apr 25 08:57:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 754647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wBxtD4xLKz9s7x for ; Tue, 25 Apr 2017 18:57:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VLblKD3I"; dkim-atps=neutral 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=HwNurLg8Cvf10sjvCHiu8b0nUhhru0SlRm3wRTMv/35cyN6mkG H1YnD7aIVivptuvWoll9Z4zoL7qEkrIkVlxfeF604fx8v+jkosKI2ksS+0wm5SID lvNsR8DYpOm/Uq8eceDYeJKPlyZB0xYwF3nErPK/kaGC+9f3zW2fOv7o0= 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=QjyGsEKIN2ATZ58ZpZvZUkz25Ps=; b=VLblKD3I+ZR65RcaTkK0 NtaaCzDqlSI6O5sRc+Ft7ajwRQ3ABs5NKCAbJPE+VWU8zSS1bsZGOyjvf6z7XBZh TzY7g4TzfQkTE1qNPrYbsS2gZF3M0HMOJuolUZym6HB6LF8yDqcFyXuHZ5+dSiNo rnHeG65IfW9XHME2idB1FQA= Received: (qmail 33910 invoked by alias); 25 Apr 2017 08:57:04 -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 33830 invoked by uid 89); 25 Apr 2017 08:57:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=outlined, Bar, Justin, justin 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, 25 Apr 2017 08:57:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CF47C3536; Tue, 25 Apr 2017 04:57:01 -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 G1TVcR+eMMqG; Tue, 25 Apr 2017 04:57:01 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id BD1D9350D; Tue, 25 Apr 2017 04:57:01 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id BBD9B521; Tue, 25 Apr 2017 04:57:01 -0400 (EDT) Date: Tue, 25 Apr 2017 04:57:01 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [Ada] Spurious compile failure with nested packages Message-ID: <20170425085701.GA47378@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch adds another condition to an edge case used to delay expression function freezing (P804-015). The offending package is within the body of a library-level unit where this edge-case does not apply. By adding a condition that only delays freezing of expression functions if we are in a library-level spec we can avoid spurious disambiguation errors. ------------ -- Source -- ------------ -- pkg.ads package Pkg is pragma Elaborate_Body; end; -- pkg.adb with Ada.Containers.Vectors; package body Pkg is package SubPkg1 is type T1 is private; function Foo (T : T1) return Boolean is (True); subtype ST1 is T1 with Dynamic_Predicate => Foo (ST1); private type T1 is null record; end; package SubPkg2 is type T2 is private; function Foo (T : T2) return Boolean is (True); private package V2 is new Ada.Containers.Vectors (Positive, SubPkg1.ST1, SubPkg1."="); type T2 is record SubPkg1 : V2.Vector; end record; end; type C is record Count : Natural; end record; type CA is array (1 .. 3) of C; package VC is new Ada.Containers.Vectors (Positive, CA); V : VC.Vector; procedure Bar is begin for P in V.Iterate loop for X of V (P) loop X.Count := X.Count - 1; end loop; end loop; end; end; ---------------------------- -- Compilation and output -- ---------------------------- $ gcc -c pkg.adb pkg.adb:15:07: warning: in instantiation at a-convec.ads:375 pkg.adb:15:07: warning: component of "Elements_Array" padded by 8 bits Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Justin Squirek * sem_ch3.adb (Analyze_Declarations): Add additional condition for edge case. Index: sem_ch3.adb =================================================================== --- sem_ch3.adb (revision 247146) +++ sem_ch3.adb (working copy) @@ -2646,6 +2646,8 @@ and then Was_Expression_Function (Next_Decl) and then not Is_Compilation_Unit (Current_Scope) and then not Is_Generic_Instance (Current_Scope) + and then not In_Package_Body + (Enclosing_Lib_Unit_Entity (Current_Scope)) then -- Loop through all entities in the current scope to identify -- an instance of the edge case outlined above and ignore