From patchwork Tue Jul 4 08:09:29 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: 115607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1053726vqx; Tue, 4 Jul 2023 01:10:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5EZYZ5IbEtQtJNuaTAzvZam5Dsn2pNCuXxBWYBB5p3xG6XiDYjpIPmaeej0TaGy5sPvAnU X-Received: by 2002:a17:907:d8f:b0:98e:3935:60f4 with SMTP id go15-20020a1709070d8f00b0098e393560f4mr15839433ejc.1.1688458243840; Tue, 04 Jul 2023 01:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688458243; cv=none; d=google.com; s=arc-20160816; b=dM58UYBbimlf8Jn3A/c5Cml8FYB6Wq9fH59XCegxcsT/7bB5tO4rYI0rMRt6qdttIB 1rdRJW/qtN3fuMkpGHzNz0W9BMWfLXgS+kWvg/IQlW5HIUgada8z99lmvqDjPZfBV3xG SxHV868T8D9RYc16Ss0msB+tHNkwgWxutr835fH15sprY8batqgs/EJ9vPktZuNSte1G 5o5YV8IKFU1qKMVBbzmTWqpHZNbG69XnnmmH4YFvldPwniewLRpTuvZ1WNTWITufVhB9 jImJyBbPyaR2K56GySb/EoIR4qwWJgDQNaEbd7j3mvftzR1Ev/jSMKGSEpKUaIwjjhZ7 lV5Q== 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=cUTsP1kcZLLpQkROK/qVBwnQS+b8w/LK+Ode9QlIbPQ=; fh=xkXw4ZjwHxuTwIHh5BpbVWFYGO+bP8cUYTTqcq/2BVI=; b=N5qwlBLIUg1WivDdXBnggEd4NHM38fo74JPkQHYI6UKx5txvjdiKYaZbfpHybRjo4x UusODLmO8DwzaCUhEgJHu4l5jLekH0OZPK90hZAwPP6BD+uvQOm/HU5dXlhzzTtPMdH1 tHIuQYm0KpgaVpJlQO2x7J/HB6/33jD6ZkAuIAPBKExV/5C0RrIzptf/zT+Ta8m1H6Pf gNAvY/Un9P+p4MX2EA2br1jZ1RNwEM+5hUYuz+BbbfkyDFxS9XWlNXeqqscCbxQTeDY4 m1nyziMcvi8ZtcR/sN9qOyQFGGAyjxmr3PSGs9b/y6XGeLbn8dXOWq2bGjgjZvGz7m5o uuow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t2+42l2y; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r16-20020a170906549000b00988c3881c33si4160731ejo.234.2023.07.04.01.10.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 01:10:43 -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=t2+42l2y; 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 4A42138560B9 for ; Tue, 4 Jul 2023 08:10:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A42138560B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688458230; bh=cUTsP1kcZLLpQkROK/qVBwnQS+b8w/LK+Ode9QlIbPQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=t2+42l2yKVEQxdkLDNx4m1T9jgSLZ4kbvoXkCigXO7SR40+4KCs0vY9acIaUs/tfZ qsllRbBezfyledj+bXOzsH59cIBBaE+rTxR8VGsNoZBsp83MVpAqH+hRXQKWAPmd3k TLMaNLzik9WlcUXBNsmenu5ki6AnDVdMApdg6vzo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id EA6CA3858D35 for ; Tue, 4 Jul 2023 08:09:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA6CA3858D35 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbab0d0b88so43511295e9.0 for ; Tue, 04 Jul 2023 01:09:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688458183; x=1691050183; 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=cUTsP1kcZLLpQkROK/qVBwnQS+b8w/LK+Ode9QlIbPQ=; b=NwjTf5UgpbbJDrlBeIbDKI/1nnXJ56ikPdRztzkIAx3JAEh79jM2U2kGiav6CZVIKG L+Z6GqhU7PURCytNcS6hGyftKWBxn5MQ8KN1IXsds/xEbrqbMcUiKIrTQqWzQlSX2RZW UjvbwLjbxofcPN5+XzGWTZyg8bmAqpmxLXxRo0VhOa4LodMmq4HXAP3chJs6rmHx7i4p EOTierKRzxK26Yen4Ig+nvX5hYZjIVLgdqR9wfb4s76hw9hjRIJSztjf+B1g4YIGo2yw /ohI7uno/cRelZqG66locfRXUaGFK9YqrnzJR7yfPOC1SNq3Mfei4v88kjm0NtBY+kPJ 8PkA== X-Gm-Message-State: AC+VfDwGrAS9LHD1fBYKXVMUtPLizCaKzuERQ0Qrgoa02I3AiXyiHx18 SIHqGF4wWCSquZATuZeUzq+W8nEK/HGoFotH8uG/vw== X-Received: by 2002:a05:600c:3d9b:b0:3fb:c257:9f48 with SMTP id bi27-20020a05600c3d9b00b003fbc2579f48mr11449500wmb.16.1688458182831; Tue, 04 Jul 2023 01:09:42 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:d29a:91eb:ac2b:8815]) by smtp.gmail.com with ESMTPSA id 4-20020a05600c228400b003fbc216b137sm13005398wmf.3.2023.07.04.01.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 01:09:42 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED] ada: Fix list of inherited subprograms in query for GNATprove Date: Tue, 4 Jul 2023 10:09:29 +0200 Message-Id: <20230704080929.998656-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?1770476791678449334?= X-GMAIL-MSGID: =?utf-8?q?1770476791678449334?= From: Yannick Moy The query Inherited_Subprograms was returning a list containing some subprograms whose overridding was also in the list, when interfaces was present. This was an issue for GNATprove. Now propose a mode for this function to filter out overridden primitives. gcc/ada/ * sem_disp.adb (Inherited_Subprograms): Add parameter to filter out results. * sem_disp.ads: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_disp.adb | 30 ++++++++++++++++++++++++++++++ gcc/ada/sem_disp.ads | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index 6c8212c3cb3..b22407aafb8 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -2530,6 +2530,7 @@ package body Sem_Disp is (S : Entity_Id; No_Interfaces : Boolean := False; Interfaces_Only : Boolean := False; + Skip_Overridden : Boolean := False; One_Only : Boolean := False) return Subprogram_List is Result : Subprogram_List (1 .. 6000); @@ -2670,6 +2671,34 @@ package body Sem_Disp is end if; end if; + -- Do not keep an overridden operation if its overridding operation + -- is in the results too, and it is not S. This can happen for + -- inheritance between interfaces. + + if Skip_Overridden then + declare + Res : constant Subprogram_List (1 .. N) := Result (1 .. N); + M : Nat := 0; + begin + for J in 1 .. N loop + for K in 1 .. N loop + if Res (K) /= S + and then Res (J) = Overridden_Operation (Res (K)) + then + goto Skip; + end if; + end loop; + + M := M + 1; + Result (M) := Res (J); + + <> + end loop; + + N := M; + end; + end if; + <> return Result (1 .. N); @@ -2702,6 +2731,7 @@ package body Sem_Disp is (S : Entity_Id; No_Interfaces : Boolean := False; Interfaces_Only : Boolean := False; + Skip_Overridden : Boolean := False; One_Only : Boolean := False) return Subprogram_List renames Inheritance_Utilities_Inst.Inherited_Subprograms; diff --git a/gcc/ada/sem_disp.ads b/gcc/ada/sem_disp.ads index 1e6c9e6f65a..a2cfec881f1 100644 --- a/gcc/ada/sem_disp.ads +++ b/gcc/ada/sem_disp.ads @@ -120,6 +120,7 @@ package Sem_Disp is (S : Entity_Id; No_Interfaces : Boolean := False; Interfaces_Only : Boolean := False; + Skip_Overridden : Boolean := False; One_Only : Boolean := False) return Subprogram_List; function Is_Overriding_Subprogram (E : Entity_Id) return Boolean; @@ -129,6 +130,7 @@ package Sem_Disp is (S : Entity_Id; No_Interfaces : Boolean := False; Interfaces_Only : Boolean := False; + Skip_Overridden : Boolean := False; One_Only : Boolean := False) return Subprogram_List; -- Given the spec of a subprogram, this function gathers any inherited -- subprograms from direct inheritance or via interfaces. The result is an @@ -143,6 +145,9 @@ package Sem_Disp is -- subprograms inherited from interfaces. At most one of No_Interfaces -- and Interfaces_Only should be True. -- + -- If Skip_Overridden is True, subprograms overridden by another subprogram + -- in the result list are skipped. + -- -- If One_Only is set, the search is discontinued as soon as one entry -- is found. In this case the resulting array is either null or contains -- exactly one element.