From patchwork Tue May 2 08:26:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 757451 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 3wHDsW1XNlz9sD9 for ; Tue, 2 May 2017 18:26:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Rcf/iy8Y"; 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=Z+n5cL+TV2xexZ0BTQ3ts+FYY727WIyFdBrxmGoFKoKtbZZ8fz x9s4pWP8IJeDJZ7p1kRSzL+nQ5aLKBdaN1iBE9UmYcNLw6388ryEzI2a1EQKE6+Q Lzea4Q27yqNnM6Z6UDxiOL2LERJhKMRffLX7DHSFqWmnJMa4QFs7uqvBo= 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=CWmQWzjfHDrr9Xe7lgVm3VChJGQ=; b=Rcf/iy8Y6iPYXd0hl757 8VrUzsW3lq8l2ltwS3eft+Gxtq7hX1/dsQ9teVzloAT50kvsjSZ62jx6p52q5Gim IsBPjT2ZLbpxN+IFpkTArbbd/PWxtqxKwqb1ozUmvF7N5DjWfa1EyA8h1pnw6OIT zpEXHebKo+9p+s4mOKEubNE= Received: (qmail 8058 invoked by alias); 2 May 2017 08:26:22 -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 7846 invoked by uid 89); 2 May 2017 08:26:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Event, occurrence, quantified 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, 02 May 2017 08:26:19 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8C17C9EBE; Tue, 2 May 2017 04:26:20 -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 H5vqo1BQRDaL; Tue, 2 May 2017 04:26:20 -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 79F0B9DC0; Tue, 2 May 2017 04:26:20 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 759774FF; Tue, 2 May 2017 04:26:20 -0400 (EDT) Date: Tue, 2 May 2017 04:26:20 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious error on aspect of a discriminated protected type Message-ID: <20170502082620.GA147005@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes a spurious conformance error on the occurrence of the discriminant of a protected type in the expression for an aspect of the type, when the type and its body appear within a subprogram body. The check that the expression has the same visbility at the freeze point of the type and at the end of the current declarative list may have to examine two different entities which result from analysis and expansion steps at the freeze point and after analysis of the body and construction of the corresponding protected subprograms. The following must compile quietly: --- with System; procedure Aspect_Bug is subtype Data is Integer range 1 .. 10; protected type Event (Ceiling : System.Priority) with Priority => Ceiling -- Ceiling priority defined for each object is entry Wait (D : out Data); procedure Signal (D : in Data); private Current : Data; -- Event data declaration Signalled : Boolean := False; end Event; protected body Event is entry Wait (D : out Data) when Signalled is begin D := Current; Signalled := False; end Wait; procedure Signal (D : in Data) is begin Current := D; Signalled := True; end Signal; end Event; It : Event (15); begin null; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-05-02 Ed Schonberg * sem_ch6.adb (Fully_Conformant_Expressions): Two entity references are fully conformant if they are both expansions of the discriminant of a protected type, within one of the protected operations. One occurrence may be expanded into a constant declaration while the other is an input parameter to the corresponding generated subprogram. Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 247461) +++ sem_ch6.adb (working copy) @@ -8770,6 +8770,16 @@ and then Ekind (Entity (E1)) = E_Discriminant and then Ekind (Entity (E2)) = E_In_Parameter) + -- The discriminant of a protected type is transformed into + -- a local constant and then into a parameter of a protected + -- operation. + + or else (Ekind (Entity (E1)) = E_Constant + and then Ekind (Entity (E2)) = E_In_Parameter + and then Present (Discriminal_Link (Entity (E1))) + and then Discriminal_Link (Entity (E1)) = + Discriminal_Link (Entity (E2))) + -- AI12-050: The loop variables of quantified expressions -- match if they have the same identifier, even though they -- are different entities.