From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 441AC3885500 for ; Thu, 6 Oct 2022 09:29:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 441AC3885500 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42c.google.com with SMTP id n12so1741946wrp.10 for ; Thu, 06 Oct 2022 02:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YarLATkB85ibi/47vrP7pH8Iz/qrrDaS2fRyt4YFCS4=; b=Kfg3+6w31XnL+rXA0PGC402a2JSedXd7eSCjhfiaROmxT8+upwYwPyAbKFIW8+S463 c7nO4531lftEALQac9JTMIYrsEKb+pT65xtEbspWZVQ5H0hYEXiE6Nu2+YEkP7u+R5Iq YJORntSEnpysQ9a3GQ6cMJJ5l863IEl2MMcNazf+BqvElIUDkAx2cZR/7DbqWrCq4C0k QLovDt/N45U8En39RssbQ/F5tHep/nKDnFyhBfclLBK5yvnN681uxjWeOgIU5kPfH2SH zJ2frCYV9BcHZyKl2T1/yJtm+wZCgJjKSptLc3WaCAKMkYYEAVzf8MRIuYmW7GM4IYAB bb4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YarLATkB85ibi/47vrP7pH8Iz/qrrDaS2fRyt4YFCS4=; b=7kf78CvcBT2pvdQTvzIB2CfrnoRgYfSldNE4219xiNKWAkypWjhspoQOf71ExL9jDg dttgAKGEQqV5fHLTtvt2XNBuGPoZRe8kV42MyMhH7YuxDkHKaWJK8QVlmndJend+hk22 EGqgQOMPXQbRVpggnNIRimHFP+nyNCuGhKB9YAGMz9hnupu+cHIzcJ6ZfuAuz04VxfIO KWOBLcAYaaaXTjQM9o1EF6rlBRKSluYAZXhPEkDivtWyNtYNf6oyQg5K4GWBa13AIvK/ +cz5Q/s5U5QU0nXA1j0jymqFSYUd0zQTRpIMwZsyhduog6goM+wxhd3dWOSdYAkL4s4j hIVQ== X-Gm-Message-State: ACrzQf1PGQ1jASukqZYYaROiXKKQ0hg7ubxZw1FLe48NellE9MQMDMDQ bI20V+1Lhj+/7B77C90yCRG5jr9OyeQQtGex X-Google-Smtp-Source: AMsMyM6p3JdW+LAFYrT+HfOpOVMyxaqqhlpdHhA8z4f22aoiLNwbG162257fdBFgkkAi9Chg7H2FvA== X-Received: by 2002:adf:cd84:0:b0:22e:2ff1:7305 with SMTP id q4-20020adfcd84000000b0022e2ff17305mr2530155wrj.650.1665048539080; Thu, 06 Oct 2022 02:28:59 -0700 (PDT) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id r67-20020a1c4446000000b003b49ab8ff53sm4719012wma.8.2022.10.06.02.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 02:28:58 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITED] ada: Accessibility error incorrectly flagged on call within Pre'Class expression Date: Thu, 6 Oct 2022 11:28:47 +0200 Message-Id: <20221006092847.260877-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Gary Dismukes The compiler was wrongly reporting an error on a function call within a Pre'Class expression when a formal of the aspect's subprogram was passed to an aliased formal. This occurred due to the call appearing with the return statement of the wrapper function created for the precondition, but the accessibility error check should only be done for return statements that appear in the source program. gcc/ada/ * sem_ch4.adb (Analyze_Call): Add test of Comes_From_Source on the enclosing subprogram's Entity_Id for determining whether to perform the compile-time accessibility check on actuals passed to aliased formals in a function call occurring within a return statement. That test excludes cases where the call occurs within the return statement of a Pre'Class wrapper function. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index ceaf66bd3e2..6824941fa34 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1467,12 +1467,17 @@ package body Sem_Ch4 is end if; -- Check the accessibility level for actuals for explicitly aliased - -- formals. + -- formals when a function call appears within a return statement. + -- This is only checked if the enclosing subprogram Comes_From_Source, + -- to avoid issuing errors on calls occurring in wrapper subprograms + -- (for example, where the call is part of an expression of an aspect + -- associated with a wrapper, such as Pre'Class). if Nkind (N) = N_Function_Call and then Comes_From_Source (N) and then Present (Nam_Ent) and then In_Return_Value (N) + and then Comes_From_Source (Current_Subprogram) then declare Form : Node_Id; -- 2.34.1