From patchwork Mon Nov 7 08:40:26 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: 16318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1922094wru; Mon, 7 Nov 2022 00:51:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM6Ha8Hr1sqhFckHuGn1XfkKV2n5xQFmWUBpKZTZLDK5MttS8ncVZcOff8ED8yug3PMy2+Js X-Received: by 2002:a17:907:8d0b:b0:7ad:c7d6:eee4 with SMTP id tc11-20020a1709078d0b00b007adc7d6eee4mr40999013ejc.454.1667811064793; Mon, 07 Nov 2022 00:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667811064; cv=none; d=google.com; s=arc-20160816; b=q2atbyg9hhfm7iH+ow3BFzB9tAqHTnsl7hiSeUDZ7F2E2bwga3H+NvIpYP6mQij0mq QEcMF6L95vkWnRD1MePidcVJ1i87KBPXf9IZilTEvgBH2WGwGdO38cPJyZ7txIY2ythi NBDYA+fcvInSY/eT6ONWPipcOIGGecuxsDoLgJCO3MCQzip7UzfOy+MOLC/HT7JSaomn 3w+8JrQjt5656Lli5cds+Ae2SKkiR81rbRTF3uH5cmeLeqdNCgEpSG8iwT5a09COdsfo lF6mSEvoPTV8RC2l+keDdvAlCf6UkYTDWJyD6PGyJCAZvKBXDavcpnfznVwLoCDLQpr2 gUPw== 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=dSbArB/7/DY+SJqkI+j7KMrU4UHE2XeujWyVssbqOv0=; b=LeR7A9mx0nEDp9/iWhst/cEoLncAxFVUSCA4H97ZDSgvzqBe52zuD7qvzm+8pqytvJ O/xDGOIub9V5ztRvK/j6x2FYX7mvWvP4MSqpQZbitsO3RZJiYkM63uIEpMqoaProTo/g d/lXrMWiy09OtZo3QGV88C9XM9fX3vR4dvNQennZdQ885XVPMXV8uh99GFcjXIC54zdx Gd0rf3QS+O060vW9a3fw+Iffsbhq3lXrdZ3rpkEIW/Xo7XNoHOPYLZrtQHYpba2LqPac Ho0CD4tzI90MshreY1cfUcWokjXpXoiFAqkVNB6vefwT/mPmxxlID7Gfzy3Zz0NTPXh3 22oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=k1m7JqpA; 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 dt4-20020a170907728400b0078df19995e4si9589368ejc.241.2022.11.07.00.51.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:51:04 -0800 (PST) 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=k1m7JqpA; 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 860BD384A078 for ; Mon, 7 Nov 2022 08:45:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 860BD384A078 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810743; bh=dSbArB/7/DY+SJqkI+j7KMrU4UHE2XeujWyVssbqOv0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=k1m7JqpAXkNq3g+gMufTefLyeqia3RLP8GGNyhFZcbuo22LL8QDBKWLOY51iu6RGm S0oE51w+B6iMWYLn1F4Tjn8ywxk5rvu4VeHFYGll/WSCM8//4QZn0i2+6dwACBFhPj Na71ct+hFIl7k06RmW6yUsvRx/XfkK72BoK8BSGw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 586BA385803E for ; Mon, 7 Nov 2022 08:40:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 586BA385803E Received: by mail-wm1-x32d.google.com with SMTP id t25-20020a1c7719000000b003cfa34ea516so1720064wmi.1 for ; Mon, 07 Nov 2022 00:40:30 -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=dSbArB/7/DY+SJqkI+j7KMrU4UHE2XeujWyVssbqOv0=; b=xuxMqxXhCfmWTGTamqnPTrTYbQiFUqXSZ3ZbkEr7px5FyX6TR72psOdKm8eUIxJqT/ T+qkh3ChyQJtquteQKrYlHWXZFq4Qx4G2moU6EEG5RKTjBjRk+OCIiieDjGqUKFVW9xp VghVnBXTE3JPCEOphtfBCMMgMakNMrS3AE44/YF9w8cFBRoJVRH6VFRoSvgQNQmbD5lN N9LZej93xP0hmlNoMRhsnvtspuiyX4oK6rp6GbjlouUWIQTOctZtcATpYxqhLkvhUC+2 YwAlGfXy0bqJoKd6Z3W5F6M75e/Ifh+queMMpisclSEuJxoBhxX1spc4jhSQdAxYwvKu oeOQ== X-Gm-Message-State: ACrzQf2AAPVdq8gqpblGwN9f9pBxlepmXmbAdlz/t9mRNgfxRd7nW5qr upxtr3bk2ni3suVTT7ztWADgX//wZbW3Gw== X-Received: by 2002:a05:600c:746:b0:3cf:705c:d8d9 with SMTP id j6-20020a05600c074600b003cf705cd8d9mr28318618wmn.42.1667810429220; Mon, 07 Nov 2022 00:40:29 -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 g17-20020a5d46d1000000b0022efc4322a9sm6630036wrs.10.2022.11.07.00.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:40:28 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Cleanup detection of code within generic instances Date: Mon, 7 Nov 2022 09:40:26 +0100 Message-Id: <20221107084026.151175-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?1748826655068833771?= X-GMAIL-MSGID: =?utf-8?q?1748826655068833771?= From: Piotr Trojanek To check if a node is located in a generic instance we can either look at Instantiation_Location or at the Instantiation_Depth, but just looking at the location is simpler and more efficient. Cleanup related to improved detection of references to uninitialized objects; semantics is unaffected. gcc/ada/ * sem_ch13.adb (Add_Call): Just look at Instantiation_Depth. * sem_ch3.adb (Derive_Subprograms): Likewise. * sem_warn.adb (Check_References): Remove redundant filtering with Instantiation_Depth that follows filtering with Instantiation_Location. * sinput.adb (Instantiation_Depth): Reuse Instantiation_Location. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 2 +- gcc/ada/sem_ch3.adb | 6 +++--- gcc/ada/sem_warn.adb | 1 - gcc/ada/sinput.adb | 4 +--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 2eb1a69e764..5507353136b 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -9930,7 +9930,7 @@ package body Sem_Ch13 is if Opt.List_Inherited_Aspects and then not Is_Generic_Actual_Type (Typ) - and then Instantiation_Depth (Sloc (Typ)) = 0 + and then Instantiation_Location (Sloc (Typ)) = No_Location and then not Is_Internal_Name (Chars (T)) and then not Is_Internal_Name (Chars (Typ)) then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 90af32091e9..76dc6325060 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -16720,9 +16720,9 @@ package body Sem_Ch3 is (Is_Generic_Unit (Scope (Find_Dispatching_Type (Alias_Subp))) or else - Instantiation_Depth - (Sloc (Find_Dispatching_Type (Alias_Subp))) > 0); - + Instantiation_Location + (Sloc (Find_Dispatching_Type (Alias_Subp))) + /= No_Location); declare Iface_Prim_Loc : constant Source_Ptr := Original_Location (Sloc (Alias_Subp)); diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 1bfa8449ad7..a1a59a8857b 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -1720,7 +1720,6 @@ package body Sem_Warn is elsif Is_Generic_Subprogram (E1) and then not Is_Instantiated (E1) and then not Publicly_Referenceable (E1) - and then Instantiation_Depth (Sloc (E1)) = 0 and then Warn_On_Redundant_Constructs then if not Warnings_Off_E1 and then not Has_Junk_Name (E1) then diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index 8e80213e314..c96049b2678 100644 --- a/gcc/ada/sinput.adb +++ b/gcc/ada/sinput.adb @@ -620,7 +620,6 @@ package body Sinput is ------------------------- function Instantiation_Depth (S : Source_Ptr) return Nat is - Sind : Source_File_Index; Sval : Source_Ptr; Depth : Nat; @@ -629,8 +628,7 @@ package body Sinput is Depth := 0; loop - Sind := Get_Source_File_Index (Sval); - Sval := Instantiation (Sind); + Sval := Instantiation_Location (Sval); exit when Sval = No_Location; Depth := Depth + 1; end loop;