From patchwork Mon May 29 08:29:48 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: 100163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1365875vqr; Mon, 29 May 2023 01:44:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZVG6fDkyCqSa41habJ1BZmXSI1vPgS+qemHq+Gi/uElaJy21k7ZSTBmdCgm1moPCGJ+9P X-Received: by 2002:a17:906:9b85:b0:965:9edf:f0d0 with SMTP id dd5-20020a1709069b8500b009659edff0d0mr6065313ejc.13.1685349852766; Mon, 29 May 2023 01:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685349852; cv=none; d=google.com; s=arc-20160816; b=czlv7uzhjxRGqoGSVOge7LvtJudkg3pm5UubWwbHlGDtFTblmP8+827BeWB9bvfjR3 QtU24ibVXjG0t8lQXMHHx0icDG3QeCwdRPAFzhfw/rlqqpUj1HvgSP9YsMCe2iDjG8eV hwcSKMYYHLbuhW2AaAr9PWT+MIqFySzWyoD5w+TSUGZoihrNrQXJuTY1L4Gr0JKG9X2k fG4opMvSGm8HRDhoDQEvVMJ+VLB2jhhCYQoY5vK2Aba51k9Y/mrTpdjgNvm8OnMUQJ1j bHbsfA/WyNZbLHL65q7JNEMxyac9bNpt0lo9RCgrjpyNtVy0CJJ1dOvQGfq6XdR4sJp1 W/yQ== 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=RjCk0Vae86YMt3UiRKrH0aKY15w34d8ovSIAIPN/5UE=; b=iN/qXIrIb19FJu8HdBZBpXyg8R7WGLBFp0owyatfzFdVgKfaOzJ7K9EeSXLH29ObKm OrO/watR8EPPBo1ex2TUdlo/PvyBIhDTw2XSUgb/CGjdUKtuOHeGvwJm4GYQ9XGhspb5 G8WyGZjpBqyAAGkWZf08mKB7KjCmiZX/lOECXlVuR4PkAa0riToeFi0QuacJmmpLscdz RHnHL3RceYAAZG/rhw1gzUaxnezHmh4Z99jxpCYllSR9f4BsIhsiX61oCpTY7OTM6cxw 96cJV1XsYf77Lc5GdcVzZt12xfuk/FgTzMVN+aQjHIbqEmbzAxKoH7btOOKM7Oiu6Pxz nuCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=e+3vMBNW; 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 gs32-20020a1709072d2000b0096f89c8a449si5789560ejc.9.2023.05.29.01.44.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:44:12 -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=e+3vMBNW; 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 066C23885523 for ; Mon, 29 May 2023 08:37:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 066C23885523 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349438; bh=RjCk0Vae86YMt3UiRKrH0aKY15w34d8ovSIAIPN/5UE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=e+3vMBNWOr5XvZ3Z4KSip4gWAOOcNGgbQdoCwxPF6S4u6v1SZ2YtBA7AJCtUxvNZ1 WF7Pc2hJXX4k4PDcRRUIOrCYkTvCfEU11v11JLmq94L92XOu5UgCci+vfhkrL6zSV0 kY1xuysguRR8ljM8SHNKynCMcqxLCus55mxtRePg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 89821384DA7A for ; Mon, 29 May 2023 08:29:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89821384DA7A Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-30ae61354fbso782556f8f.3 for ; Mon, 29 May 2023 01:29:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348989; x=1687940989; 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=RjCk0Vae86YMt3UiRKrH0aKY15w34d8ovSIAIPN/5UE=; b=TEYXUKkJ0gd6zF5WZmdagH/+Xtj6QCuV1ewilE3pUdoshBMW1lrGt6nGhWF+aygXCA 2vYvwvRtxthYBK5XEXIQznAfxG/miZV0oCj7ZyEefe9oFmvhtgIiPvVKMVXzR6Wr/FDy 68WCZFypUD7Jt3fzmBlEfsbjeHQWGrsyoMfFtGfVe37342bFh1eKGcaZJ0i/4KKCeBQz oUUe9v0kZ/v6qTqMH8Dp2dSrPyJyf3FjvoRke2zO3A5kjcGhpuVOj24Yg+XDOjxkT/Uv 3Qen8pLRAz2PzjwHeTrXj6ukviEnQxbl6GbPWqb+RU9xLD3X1fvU5lKFGLAxjtdqrl2X ZafA== X-Gm-Message-State: AC+VfDzJhX5SLI6DWFmsZxJf6M6ZEz9tA4YQKWwgI2Hp51Ds/OfkOXpw 4t4/UAmmDh+8jLdK9dLWAhOQ46d49TQSFKsgtb1aPA== X-Received: by 2002:adf:ce91:0:b0:306:34f6:de8a with SMTP id r17-20020adfce91000000b0030634f6de8amr8219869wrn.71.1685348989380; Mon, 29 May 2023 01:29:49 -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 k5-20020adfd845000000b0030ae53550f5sm6106839wrl.51.2023.05.29.01.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:48 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Fix crash on semi-recursive call in access-to-subprogram contract Date: Mon, 29 May 2023 10:29:48 +0200 Message-Id: <20230529082948.2411007-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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?1767217407354876662?= X-GMAIL-MSGID: =?utf-8?q?1767217407354876662?= From: Piotr Trojanek Calls to access-to-subprogram from its own pre/post aspects are rejected as illegal, e.g.: type F is access function (X : Natural) return Boolean with Pre => F.all (X); but they caused an assertion failure in detection of recursive calls. Now they are properly recognized as recursive, but the error is suppressed, because it has been already posted at the call node. gcc/ada/ * sem_res.adb (Invoked_With_Different_Arguments): Use Get_Called_Entity, which properly deals with calls via an access-to-subprogram; fix inconsistent use of a Call object declared in enclosing subprogram. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1d4b9acb8ea..8a5f87b80ed 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -947,7 +947,7 @@ package body Sem_Res is -------------------------------------- function Invoked_With_Different_Arguments (N : Node_Id) return Boolean is - Subp : constant Entity_Id := Entity (Name (N)); + Subp : constant Entity_Id := Get_Called_Entity (N); Actual : Node_Id; Formal : Entity_Id; @@ -956,7 +956,7 @@ package body Sem_Res is -- Determine whether the formals of the invoked subprogram are not -- used as actuals in the call. - Actual := First_Actual (Call); + Actual := First_Actual (N); Formal := First_Formal (Subp); while Present (Actual) and then Present (Formal) loop