From patchwork Thu May 25 08:05:52 2023 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: 98855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp198809vqr; Thu, 25 May 2023 01:16:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4iQg6XUu9r/EiEoD/1aLKBYF+fWRE7tGzZu5vV/Xf97wI7rxvTzxSoCFKYrGfmLBOkWmuA X-Received: by 2002:a17:907:3d91:b0:96f:f50b:9b15 with SMTP id he17-20020a1709073d9100b0096ff50b9b15mr876675ejc.35.1685002618906; Thu, 25 May 2023 01:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685002618; cv=none; d=google.com; s=arc-20160816; b=Hj2q4xYVOupVORABN/Oa8n3RJDrCHQ48rdta8yE3+wp9BW0qPP4SsYVcImX1bAViDc u/7GVhuRVE/eHH8zimgA3iNFuxPUKX+ERdvmAuizaWjU2g5jMik1K9GroMDVUBdS2039 ZLtzU1PQw8SsNSrKqtbO5vWZv5hpBwWXUJgWiJLJ1sFNIxegyjQPRPIZOSbdzggkNjqe iaZ/WgoqH4JzydbdYQianYYr/6dDuQYM8qo2/BoaFp7W+oPQWuEpu/oVTRI16MreLzX/ A9yTOafA2wfUWFl0XbMZbL3gDTENrb6Ss1pfJk4BP10AE7uPkTjMA1VATYQ4oire2AUy 9lWg== 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=p0QRpk6hyJILCOcRBtPHq6Nh2hkn94Y7JKWd3EFsapw=; b=hXEb6IB7IqMjjWuQpOlZ+UGWh2YuPKt5Lc/GpnQ0FzDyV+lKkjqqJj8pqzV5IQL7fD twP9iUOM8zXaBjuYWwFwxiOJ83kcodJ2ZqexYCG4Xk0AQfInUpctAU85RIltxRiODvRn UgN7bZ07N0ecx6jhZxvdFsMR4+VSlkp/nZfMNfO5zqvn0f0rUKWntJZyaaMLJns32ECF Z/07AqPhsUblTC4MDV6Pkx35vbdvK3JOXwzyubgLjMJmS1DG32LkhcruFplFGDm4XZwk 8jo46HYRqj2JlRbzc79IHhgNRJS+Ft7RdzoCbv4eSTAXwo79NSgGGNX3xOcgdmGCHHpE enFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=n+iQdCjg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id tc8-20020a1709078d0800b0096f739c3d90si782361ejc.37.2023.05.25.01.16.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=n+iQdCjg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 0DD5038323C2 for ; Thu, 25 May 2023 08:11:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DD5038323C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002286; bh=p0QRpk6hyJILCOcRBtPHq6Nh2hkn94Y7JKWd3EFsapw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=n+iQdCjg24SWyLQd22m0s5lrtL+nUtzf/puS3hE+s9IR5ilg4jyWBMJhv6pDG34yG OmkLzhuzIBx4bgS3WMgOPF24ZQkZ3DqYDmzvvPvI/bYDL+b5LWbRj3316su5sUEliI pSm5/W+d2rdLVg5mJcbytn6DDljz7ZF428gxIDwA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 2CECE3855586 for ; Thu, 25 May 2023 08:05:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CECE3855586 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f42ba32e24so1919795e9.3 for ; Thu, 25 May 2023 01:05:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001954; x=1687593954; 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=p0QRpk6hyJILCOcRBtPHq6Nh2hkn94Y7JKWd3EFsapw=; b=iNQTT3pN8YsNYOzzJ6R517J3BeWU5XC7m5APTdQYY5dlw9zGpUffOY2LU+hc0j4J8q jTZGIqHkXNtuSp7ilLhwL6nNiVGQ/fJocQSgy/oCYmXt9VZGokEphsTHhyjFP5hEPvtE Lr0+UJpMbI0bYaHwDtYvIDskSq+mlw8wR3ubKHqsvl8dhVnGBfTCxOqCMNh68BEotLl9 WZzFYt2UIvbg+33AQbCgm7jW2o2xMpBAA8Wf0HG984OUvONIkeqYMyLvx2C8R/pG5Y33 KcoMJ3iK4xBk4WItJgs2BVc9QbQxMxCeymr3hEiOme7tAUgGm9gY7VBjFK9/l/oF8sgd 10Ug== X-Gm-Message-State: AC+VfDzSTryf3xbe0F0fgHLLlqch7ZIEAtsfFz+nx35vE+oEBXW+xMzu se/BXVtumT2cW/62ZGSMNSCSJkhGi3LsSaU0L6TDVw== X-Received: by 2002:a5d:4f0b:0:b0:306:2dc3:8b67 with SMTP id c11-20020a5d4f0b000000b003062dc38b67mr1402927wru.53.1685001954076; Thu, 25 May 2023 01:05:54 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id t16-20020a1c7710000000b003f604793989sm4781143wmi.18.2023.05.25.01.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:05:53 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Prevent search of calls in preconditions from going too far Date: Thu, 25 May 2023 10:05:52 +0200 Message-Id: <20230525080552.1956593-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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, T_SCC_BODY_TEXT_LINE 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?1766853306548756133?= X-GMAIL-MSGID: =?utf-8?q?1766853306548756133?= From: Piotr Trojanek When determining whether a call to protected function appears within a pragma expression we can safely stop at the subprogram body. Cleanup related to recently added support for a new SPARK aspects, whose implementation was based on Contract_Cases. gcc/ada/ * sem_util.adb (Check_Internal_Protected_Use): Add standard protection against search going too far. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 2e2fb911c38..bfe1b9fc74d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -3501,6 +3501,11 @@ package body Sem_Util is ("internal call cannot appear in default for formal of " & "protected operation", N); return; + + -- Prevent the search from going too far + + elsif Is_Body_Or_Package_Declaration (P) then + exit; end if; P := Parent (P);