From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 7D4563850862 for ; Tue, 6 Sep 2022 07:16:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D4563850862 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x436.google.com with SMTP id b16so14017252wru.7 for ; Tue, 06 Sep 2022 00:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=aSRS3edLOjXq9rNNjUaJTZGYpc2twMVM2ei3zpcvFkM=; b=lfI6l7FUjF+yHHpNZLLpNxpiHN8fjG//D7XW/c7lC2tbNKK+JAils/c/u6mwRKtJ+w c4MO3RzExo1reI7drSVySFYfmez/mS/YU/+uXAM6yJYbwA9CukKxE9mZD47BxZXDnThx OLh2v9LsiikTSrPewKdAdBdkxk2gNvv/1zwTJ/d7ROaHjeBIbI3uWh7rrXJiOQV0Bt7S PDYptYrm3eh1wwkiEORvLR5/ywToJGgbsxl4o+juzPTbLgl7n3qb9sbehtN2rKeZh7nu XEBfuCCpXXhcz0bGfICyVLwF3nPSD+L7Bycqw+ctb2DybVo6Ufjl9FJCg4BxP3mmj4dr t0zQ== 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=aSRS3edLOjXq9rNNjUaJTZGYpc2twMVM2ei3zpcvFkM=; b=5k06AAlDFOyAI3N2VjqhW+sWQMYySNzM9H79C4mUae0ZnK3/afQoMMbCaut3gqkOlC WcoQ7GoG3rjmVWFIHl1JsSrDRR+C9vgqQ9DnfGeH6tnWmM1zs4VCeF/13w8ZSdt0wtjQ nppIFqVK21SFl6GB9uqqbLzwY6x9CyiKWscnbFJgmEvwkpbtw4bTNBCF3cBpHA+nmvpm e6yNQgEWuWtl3OoEOUrXqHH3rXIQN1RuYm6k9AcozbwViuSwWEm1PWGWuJpqrpZVevzU Xh2YRzfPrEEAtYcbZO+M9IDeadi1k/rKwlVkKRtGf68hZcqON+svtjbvGiMErgRxv9HY xvTw== X-Gm-Message-State: ACgBeo3pviW8687WtR7EUXwOAhlJ0SxmgWo8fKWbgsBTn7a2yUL42DCN fd13v9nO/2AeD3sWykc5BIXKMCkM/TrF+Q== X-Google-Smtp-Source: AA6agR7VAPqQdUhQ9LMcrcMGWjIue+Xpvk1Gf8HWQLpkXRco+fGlDEQTpeNeZ2sFPAL8dAxnbJz6uQ== X-Received: by 2002:a5d:5581:0:b0:20f:fc51:7754 with SMTP id i1-20020a5d5581000000b0020ffc517754mr27436787wrv.413.1662448566180; Tue, 06 Sep 2022 00:16:06 -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 p28-20020a05600c1d9c00b003a5b788993csm13748376wms.42.2022.09.06.00.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:16:05 -0700 (PDT) Date: Tue, 6 Sep 2022 09:16:05 +0200 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix problematic line debug info attached to call to finalizer Message-ID: <20220906071605.GA1280575@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2fHTh5uZTiUOsy+g" Content-Disposition: inline X-Spam-Status: No, score=-13.0 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 List-Id: --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The End_Label is not defined for body nodes so a small tweak is needed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc (At_End_Proc_to_gnu): Use the End_Label of the child Handled_Statement_Sequence for body nodes. (set_end_locus_from_node): Minor tweaks. --2fHTh5uZTiUOsy+g Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -3806,18 +3806,27 @@ static void At_End_Proc_to_gnu (Node_Id gnat_node) { tree proc_decl = gnat_to_gnu (At_End_Proc (gnat_node)); + Node_Id gnat_end_label; /* When not optimizing, disable inlining of finalizers as this can create a more complex CFG in the parent function. */ if (!optimize || optimize_debug) DECL_DECLARED_INLINE_P (proc_decl) = 0; + /* Retrieve the end label attached to the node, if any. */ + if (Nkind (gnat_node) == N_Handled_Sequence_Of_Statements) + gnat_end_label = End_Label (gnat_node); + else if (Present (Handled_Statement_Sequence (gnat_node))) + gnat_end_label = End_Label (Handled_Statement_Sequence (gnat_node)); + else + gnat_end_label = Empty; + /* If there is no end label attached, we use the location of the At_End procedure because Expand_Cleanup_Actions might reset the location of - the enclosing construct to that of an inner statement. */ + the enclosing construct to that of an inner statement. */ add_cleanup (build_call_n_expr (proc_decl, 0), - Present (End_Label (gnat_node)) - ? End_Label (gnat_node) : At_End_Proc (gnat_node)); + Present (gnat_end_label) + ? gnat_end_label : At_End_Proc (gnat_node)); } /* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Subprogram_Body. */ @@ -10418,7 +10427,6 @@ set_end_locus_from_node (tree gnu_node, Node_Id gnat_node) gnat_end_label = End_Label (Handled_Statement_Sequence (gnat_node)); else gnat_end_label = Empty; - break; case N_Package_Declaration: @@ -10439,7 +10447,7 @@ set_end_locus_from_node (tree gnu_node, Node_Id gnat_node) transient block does not receive the sloc of a source condition. */ if (!Sloc_to_locus (Sloc (gnat_node), &end_locus, No (gnat_end_label) - && (Nkind (gnat_node) == N_Block_Statement))) + && Nkind (gnat_node) == N_Block_Statement)) return false; switch (TREE_CODE (gnu_node)) --2fHTh5uZTiUOsy+g--