From patchwork Mon Nov 7 08:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 16324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1923206wru; Mon, 7 Nov 2022 00:54:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM4nbyTfhIFRVJleUahUtfBOsT5FYyBGyxAdAhfSLDGrUfxVXHN5K8cbaMN4C8rM3GG7UFac X-Received: by 2002:a50:fb15:0:b0:464:4947:133 with SMTP id d21-20020a50fb15000000b0046449470133mr20560896edq.231.1667811253854; Mon, 07 Nov 2022 00:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667811253; cv=none; d=google.com; s=arc-20160816; b=nalrT2gFysRlpoHCnJ3XbVR9v7Aad14lbSOd6+41ct9hwOga3p1/HHG4sJI+w8JBZ+ xjazX1zcNeRx5LbtCTc83HQSv7jdH8nzPolITy+LExD8VWe5ptsIgWPGAXqKRL3XN90s D7AEuDJM+/1/3yGt9DrgHTCUf0lgKy6k4drUZT0E075LskRRLVuubImxp9tHoU06QaoB p/9YXonOxOlJaUX2zaR0Vjk8RB6sx3sUVemnySxRvrXpo6CStCxSgb+45YR0G3wmpglO I6PYZzWlN9p8fVlo3P/orxMnHdPCo05yGAPWxt8Wz758kGPfynJAiusSxsHxWrZyx0bT SShA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=0NKWJDxY9YNBmqepM195ojM+vIYhS02RbRJIZu37w8Q=; b=tGSJSU9kqNGN+1TYgJ5EktTKFbxReyepKvUOFp72cGYJpN6YJIVAfItwwgj3HsyneY 4FK3430c3ZRsmRYbuPJnwhMYj70wpLp2aFT+eOHpYMrudhJs007XSK5yA2wXuQEWgqp0 qRTZpfr+yhZVKVCTnednJ0f2Fkc4KhLgYQeweutXKpkeyey3MdkZTvMAbsupVv4M1JEi KjPF8Arf5SoZtJtRxpL0GIAw0+GIeIvopG4S8hQX3M729L6CGGCe04KTP7+jUYYVlP79 qNv8gQlZDb7yl2kznIHTO7/DDf/d6kNrvM3YYbT47zKEF8hKWDDIhrvsfWC0ybuV/qjg ysmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Hi61wmHc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g22-20020a1709065d1600b007ae664aa7dbsi5131863ejt.877.2022.11.07.00.54.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:54:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Hi61wmHc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 309913858285 for ; Mon, 7 Nov 2022 08:47:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 309913858285 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810877; bh=0NKWJDxY9YNBmqepM195ojM+vIYhS02RbRJIZu37w8Q=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Hi61wmHcbE7MAWWg5kfhtFHDXtCzeK23VkLXxOKqw82uj1Y2e6s6iOzZJnIyz2fcu P3shIcvA4kEXFwdqc6L/QXGREFTb9aTqHjdpZj7+UI/b9JdX65npjE8Qwf3+vu+3Rz rb6g47Swv/dXAlCFZKeMq9PP7rDbzwTSYdV22NFo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id C149A3857B9A for ; Mon, 7 Nov 2022 08:40:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C149A3857B9A Received: by mail-wr1-x42e.google.com with SMTP id k8so15088206wrh.1 for ; Mon, 07 Nov 2022 00:40:58 -0800 (PST) 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=0NKWJDxY9YNBmqepM195ojM+vIYhS02RbRJIZu37w8Q=; b=l6a6+7PJsJNtZp28cT1rhr9Bir7rEBmB3YSn2Acy8MBSjDIOcULnsbus2YIcqQ9k3h CQ7GVVNlor87f4O4uOJWitl9Is5Pk0vpmNg0RmN8r6YAqSSqJP6nLFiyZ+VYw4iMmFQj uGF4e378Mx2An1kNNVYR/qWTECWscqzTe7fsskaA3JlELtY9xQj7GGboxpLDRE3UQ1wo WzjaPEzIWYvtuDj156ZgQeUwY2UPSZcB4sOzuNg5kg7UMuw6R3i5uuHQFiiI2UcccWTJ Jg32sahTHOMhpD2CO+ptKEfX39Umzc2yl0petaVac7OQjc54ZmMtueVUqWS3IFU3b7xN d3KA== X-Gm-Message-State: ACrzQf2ts71bacROSRaEchNVzxrEED9yQJfosNIb2WhxAMxO+QBh3O3f sP0sCXD+iBJQz2TI7Na4nxdkGVoPfAWBhg== X-Received: by 2002:a5d:690a:0:b0:22c:dd11:7cac with SMTP id t10-20020a5d690a000000b0022cdd117cacmr524880wru.205.1667810457657; Mon, 07 Nov 2022 00:40:57 -0800 (PST) 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 bn9-20020a056000060900b00228cd9f6349sm6628848wrb.106.2022.11.07.00.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:40:57 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Fix detection of external calls to protected objects in instances Date: Mon, 7 Nov 2022 09:40:55 +0100 Message-Id: <20221107084055.151501-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748826853369482894?= X-GMAIL-MSGID: =?utf-8?q?1748826853369482894?= From: Piotr Trojanek Detection of external-vs-internal calls to protected objects relied on the scope stack. This didn't work when the call appeared in an instance of generic unit, because instances are analyzed in different context to where they appear. gcc/ada/ * exp_ch6.adb (Expand_Protected_Subprogram_Call): Examine scope tree and not the scope stack. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 9380f3dab0f..0fa97688c5b 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -6240,7 +6240,7 @@ package body Exp_Ch6 is -- The object may be a component of some other data structure, in which -- case this must be handled as an inter-object call. - if not In_Open_Scopes (Scop) + if not Scope_Within_Or_Same (Inner => Current_Scope, Outer => Scop) or else Is_Entry_Wrapper (Current_Scope) or else not Is_Entity_Name (Name (N)) then