From patchwork Mon Sep 5 07:26:03 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: 971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp57613wrt; Mon, 5 Sep 2022 00:32:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7TItZBDpDiUbF/ZwBrj/4ickgcdZ6+ZtycwYjueDBxWrsUDmT2Zcgq5ggsseA05drX3IZ7 X-Received: by 2002:a17:907:3f22:b0:73d:9a03:2abf with SMTP id hq34-20020a1709073f2200b0073d9a032abfmr34290378ejc.518.1662363132003; Mon, 05 Sep 2022 00:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363132; cv=none; d=google.com; s=arc-20160816; b=QVWyB/AqvrVJKeZ7SAaoDsKKiECKxZJB3a7kJuwQUMfCTwIbifBYz1VYUT+UrC20FM IDC65GyGhpSVEK3qLHtclXYbYAiL6frwcbdOtBPzh2OplkPE4zIbad/Nwopof3ufvpCw hKaiayE6Vd6py+gaKBgIv03YzJhQYWnoJPE2qCWsLTrHp67zb35TjPzXP1JfB7tzMeRv tXo/EceCw5NNygFkdgAdcMRHhYJUXZKbtwubUcSrQcpxdEpbeM6Q79t2JIgI8xnsqxkg TLDbLLh7Jfn92rgD02Pb1zAPqNSXTIav3sWy/ghKvxKkor3VrpzJjsXcogUglZGrm/i8 fgtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5ZBDOO1VoiZxqJWsqsDRzGqRK9DGGIYRcfJS/aMK1OA=; b=CQt9tn3D9AL28verMTfXW+lWUzfcnJhqQb8LbGYind+bpraZqlwv5FEeDGYeMKzpkU m9rW/ta5meTSLYEeAPL3BvWwBoMNRhh8LJ0t+5YzMbyNBDdP9dk/hxBUJeGBNGBCPPUv SU3OfjUm+G/5PB+rFPdAgbaKdPw3pMjsLjZ7/2mzaze1TvEGbuYf1Up7Uu01aH6HXTfK HF/tvioZNyqtHW/Zru/FfAIMVIQ6sGbJmsY84ZnkA7llvPsPTpwRob8/u+kr2oKP0aUi L4h7eKEkfAyIbThr5a7TmpU8b5JgGwBKdO1DeVQfBciXI52hEr1DXgbHcc7syqskXs09 kbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mDvVxqKO; 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 gt11-20020a1709072d8b00b0072b4063eca2si8293078ejc.559.2022.09.05.00.32.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:32:11 -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=mDvVxqKO; 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 52F413856959 for ; Mon, 5 Sep 2022 07:28:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52F413856959 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662362934; bh=5ZBDOO1VoiZxqJWsqsDRzGqRK9DGGIYRcfJS/aMK1OA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=mDvVxqKOUYptnUPRgwMqnf5x41B3e2sCIc590JG01I/7Y3XqFtmWOQrVvCBkrIq9N UlXXwhEyBtpcBOlaAsiqtAWfPkMDLE5OvgAanZY9jG+mfT1CGg7YI85FWgxqGsNcvI 8OFSRx5yGenYm+P4GfHJ+UY/63l3DeazueEXCLF8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 285393856DFC for ; Mon, 5 Sep 2022 07:26:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 285393856DFC Received: by mail-wr1-x42f.google.com with SMTP id t7so5044358wrm.10 for ; Mon, 05 Sep 2022 00:26:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=5ZBDOO1VoiZxqJWsqsDRzGqRK9DGGIYRcfJS/aMK1OA=; b=k5dT3KqzZMlxDCnfMXi6uMGeawb8Th16DYSc0Y15BnIVGM9DQ8IQNB1Hv58Zg285w/ QeaIeRo4S+bHnGL0nqKqapP03TCdF/r/Gpw0tWP1ZRStfHydij84sMUIsUuXghOwZy4U NosVbEkXJndcsIsnAvyDJexaFqwzr8h25WEoUXxCsuR2vagVlwlKSXQNLvuUtfW9nNhX TBHFZJQSk18HqOYJD0wPIPvEl8zB217FaeOM/UHX19s33KIvQj9FYdLZl2EPD6QVWfpy 2IjfXlIwgom4v6KKJexhYJetNQN46/3f+d/LsW3Tm+5d2bqKNIUXLE1CO/872Vf6stAx QNHQ== X-Gm-Message-State: ACgBeo3uL39uGl8wphxgExL1ejJvSU8K4m55H8D1h9Z8fSVFxanFb67z 91HCSsMCDh2t/jLwY/yp0vtpb0iTx/+fng== X-Received: by 2002:adf:e199:0:b0:228:60f6:f775 with SMTP id az25-20020adfe199000000b0022860f6f775mr4777003wrb.478.1662362764998; Mon, 05 Sep 2022 00:26:04 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id i14-20020a05600c354e00b003a5dde32e4bsm16773910wmq.37.2022.09.05.00.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:26:04 -0700 (PDT) Date: Mon, 5 Sep 2022 09:26:03 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Suppress warnings in trivial subprograms with finalization Message-ID: <20220905072603.GA1174684@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.5 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: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Bob Duff 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?1743114083473670850?= X-GMAIL-MSGID: =?utf-8?q?1743114083473670850?= There are heuristics for suppressing warnings about unused objects in trivial cases. In particular, we try to suppress warnings here: function F (A : Integer) return Some_Type; X : Some_Type; begin raise Not_Yet_Implemented; return X; end F; But it doesn't work if Some_Type is controlled. This patch fixes that bug. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Use First_Real_Statement to deal with this case. Note that First_Real_Statement is likely to be removed as part of this ticket, so this is a temporary fix. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5409,14 +5409,20 @@ package body Sem_Ch6 is -- we have a special test to set X as apparently assigned to suppress -- the warning. - declare - Stm : Node_Id; + -- If X above is controlled, we need to use First_Real_Statement to skip + -- generated finalization-related code. Otherwise (First_Real_Statement + -- is Empty), we just get the first statement. + declare + Stm : Node_Id := First_Real_Statement (HSS); begin + if No (Stm) then + Stm := First (Statements (HSS)); + end if; + -- Skip call markers installed by the ABE mechanism, labels, and -- Push_xxx_Error_Label to find the first real statement. - Stm := First (Statements (HSS)); while Nkind (Stm) in N_Call_Marker | N_Label | N_Push_xxx_Label loop Next (Stm); end loop;