From patchwork Fri Dec 13 09:55:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1209049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515848-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cwioJ1D7"; 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 47Z5d71Bwnz9sP6 for ; Fri, 13 Dec 2019 20:55:20 +1100 (AEDT) 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=jgUX5FAn014SHmu+7Z0M8GQNMsekvVa6y5ZZVGieMRg/NV1Aq9 Q0OsuE/WlkMk++ze4ZDDIxp18a2MU7Dbu31PD18Ix74JX9a3FT3duHfK5hIXZiV7 IP8HJhNNrDKnjdUACrWTH3ZGI86KCF2dcrs8dDhk0HkE1G5ZTH81hSdOc= 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=bDKDCncLErMIJgP6J5OpD3wHseU=; b=cwioJ1D7j/riyED/O27u wYpbppEPCSVcFg7m0BubZSqafDb8HuF73dpQiZoKBYZ6EtDb9u+I3de0RC2HI24x ckxMsxoYxKwmBZFn9zpRxY+UpwCZrhkD2cz27Dr/4jR7/M7UY8anvg8TrCpFFpBA 2cM9Fzo+zDChbG3F9zo15Xs= Received: (qmail 36513 invoked by alias); 13 Dec 2019 09:55:07 -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 36472 invoked by uid 89); 13 Dec 2019 09:55:05 -0000 Authentication-Results: sourceware.org; auth=none 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.1 spammy=safer, sem_ch6.adb, arises, sem_ch6adb 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; Fri, 13 Dec 2019 09:55:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 86376560A8; Fri, 13 Dec 2019 04:55:01 -0500 (EST) 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 cKnE9Mh5Ks4m; Fri, 13 Dec 2019 04:55:01 -0500 (EST) 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 7052A560A2; Fri, 13 Dec 2019 04:55:01 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4862) id 6C83C157; Fri, 13 Dec 2019 04:55:01 -0500 (EST) Date: Fri, 13 Dec 2019 04:55:01 -0500 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [Ada] Spurious error on overriding controlled primitive Message-ID: <20191213095501.GA13872@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch fixes an issue whereby the compiler generates spurious ineffective overriding subprogram errors on instantiations of generic child packages where such packages contain overriding controlled primitives for types extended from parent packages which are, in turn, private controlled completions. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-13 Justin Squirek gcc/ada/ * sem_ch6.adb (Check_Overriding_Indicator): Modify condition to take into account the modification of the Is_Hidden flag within generic instances. (Verify_Overriding_Indicator): Add an exception for controlled primitives within an instance. --- gcc/ada/sem_ch6.adb +++ gcc/ada/sem_ch6.adb @@ -3304,7 +3304,18 @@ package body Sem_Ch6 is then null; - elsif not Present (Overridden_Operation (Spec_Id)) then + -- Overridden controlled primitives may have had their + -- Overridden_Operation field cleared according to the setting of + -- the Is_Hidden flag. An issue arises, however, when analyzing + -- an instance that may have manipulated the flag during + -- expansion. As a result, we add an exception for this case. + + elsif not Present (Overridden_Operation (Spec_Id)) + and then not (Nam_In (Chars (Spec_Id), Name_Adjust, + Name_Finalize, + Name_Initialize) + and then In_Instance) + then Error_Msg_NE ("subprogram& is not overriding", Body_Spec, Spec_Id); @@ -6427,13 +6438,18 @@ package body Sem_Ch6 is -- If there is an overridden subprogram, then check that there is no -- "not overriding" indicator, and mark the subprogram as overriding. + -- This is not done if the overridden subprogram is marked as hidden, -- which can occur for the case of inherited controlled operations -- (see Derive_Subprogram), unless the inherited subprogram's parent - -- subprogram is not itself hidden. (Note: This condition could probably - -- be simplified, leaving out the testing for the specific controlled - -- cases, but it seems safer and clearer this way, and echoes similar - -- special-case tests of this kind in other places.) + -- subprogram is not itself hidden or we are within a generic instance, + -- in which case the hidden flag may have been modified for the + -- expansion of the instance. + + -- (Note: This condition could probably be simplified, leaving out the + -- testing for the specific controlled cases, but it seems safer and + -- clearer this way, and echoes similar special-case tests of this + -- kind in other places.) if Present (Overridden_Subp) and then (not Is_Hidden (Overridden_Subp) @@ -6442,7 +6458,8 @@ package body Sem_Ch6 is Name_Adjust, Name_Finalize) and then Present (Alias (Overridden_Subp)) - and then not Is_Hidden (Alias (Overridden_Subp)))) + and then (not Is_Hidden (Alias (Overridden_Subp)) + or else In_Instance))) then if Must_Not_Override (Spec) then Error_Msg_Sloc := Sloc (Overridden_Subp);