From patchwork Tue Oct 4 22:52:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1686156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=IhWIufl+; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MhtJw0TqKz23jM for ; Wed, 5 Oct 2022 09:53:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 82C1A3858428 for ; Tue, 4 Oct 2022 22:53:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82C1A3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664923980; bh=uYO4i0hudg2aUGpe0fWrXaGeJtAyWfXFgR8rSYisIVE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=IhWIufl+cbOXXTnf6xPg31VON8le3oTxxRURF8kGtPTX7+T9Ye/MzjY3w4z8xRopO +zrwqb/0U+4Hz9l2uV+gZ7t+syTNm1O56uzFAZKcvpa+bvLhbLqEx6TKv3iz1mUHl+ ipFKQ7eDxfDYP9qI/klhIM2brR1H9VfbxqTEBI4g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 002293858C50 for ; Tue, 4 Oct 2022 22:52:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 002293858C50 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-523-a4oqo4qeO6OwaLRBLvMzpQ-1; Tue, 04 Oct 2022 18:52:33 -0400 X-MC-Unique: a4oqo4qeO6OwaLRBLvMzpQ-1 Received: by mail-qk1-f200.google.com with SMTP id h8-20020a05620a284800b006b5c98f09fbso13056572qkp.21 for ; Tue, 04 Oct 2022 15:52:33 -0700 (PDT) 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:to :from:x-gm-message-state:from:to:cc:subject:date; bh=uYO4i0hudg2aUGpe0fWrXaGeJtAyWfXFgR8rSYisIVE=; b=zFDGs8PK+ICHW5Riu4c8w/ulciOXqy1K9fDbMjdtQxwyzNBGNWGk/ZgeJj/Y3s+tTD IGVKQbkre0W1GwTo6IKwqWB+bUtJMD7tM2e8HCulClRAOZaz9r1t65hcdqcUjKCHuW7P pLixmlb4xDq4MCibQc2PP7xtzw5Se5NmTf5AWMA3za3Ogwhro9+JIffDYjPbzCz7yYjL J9qWs/+l5wJiXu/Z/f1MYvM0sIo84pO83fTSuLD9oklhwHPfQ8VB1qmZLC1dA3Cz9Q/C UEMJkFZnlL76VEXuenaN10jfPXvqa15kQTt2wUZfMbAeEOqfulVXzDcfa/Pw4ezXnyos 3ztw== X-Gm-Message-State: ACrzQf2Jd3bFge4nJu2ZrOz+SgRschpwlt6TryV/FfSIOTSQBDvlR9tu b/mnr4h63nFXB/BdUMd0L/4sXfjXSKToGl5Yyn+F8rSVJuK4Qk8yBqsuilq7nt48X145J1qs4mI Erd9Co0Um7TeynasLX028C+gn2RYsDSEN3Wp27hnCiswjEkmC32wl16HgpVkNKrUeyQ== X-Received: by 2002:ac8:5750:0:b0:35c:cb1b:2639 with SMTP id 16-20020ac85750000000b0035ccb1b2639mr21800729qtx.183.1664923952845; Tue, 04 Oct 2022 15:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ffY+jC6jCBlhF0JAnqSI1BKjUyna/EMv2D0JGrwGbtut4XGj5tHWrTqr++YpcapdsyK69qA== X-Received: by 2002:ac8:5750:0:b0:35c:cb1b:2639 with SMTP id 16-20020ac85750000000b0035ccb1b2639mr21800715qtx.183.1664923952482; Tue, 04 Oct 2022 15:52:32 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id k4-20020ac84784000000b0033b30e8e7a5sm12354026qtq.58.2022.10.04.15.52.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 15:52:31 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: fix debug info for array temporary [PR107154] Date: Tue, 4 Oct 2022 18:52:29 -0400 Message-Id: <20221004225229.3104706-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-pc-linux-gnu, applying to trunk. -- >8 -- In the testcase the elaboration of the array init that happens at genericize time was getting the location info for the end of the function; fixed by doing the expansion at the location of the original expression. PR c++/107154 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_genericize_init_expr): Use iloc_sentinel. (cp_genericize_target_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/debug/dwarf2/lineno-array1.C: New test. --- gcc/cp/cp-gimplify.cc | 2 ++ .../g++.dg/debug/dwarf2/lineno-array1.C | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C base-commit: 49c3e9dfc5e23a335f4057efffbff2273e3c4631 diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index cca3b9fea33..404a7699a72 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -920,6 +920,7 @@ cp_genericize_init (tree *replace, tree from, tree to) static void cp_genericize_init_expr (tree *stmt_p) { + iloc_sentinel ils = EXPR_LOCATION (*stmt_p); tree to = TREE_OPERAND (*stmt_p, 0); tree from = TREE_OPERAND (*stmt_p, 1); if (SIMPLE_TARGET_EXPR_P (from) @@ -935,6 +936,7 @@ cp_genericize_init_expr (tree *stmt_p) static void cp_genericize_target_expr (tree *stmt_p) { + iloc_sentinel ils = EXPR_LOCATION (*stmt_p); tree slot = TARGET_EXPR_SLOT (*stmt_p); cp_genericize_init (&TARGET_EXPR_INITIAL (*stmt_p), TARGET_EXPR_INITIAL (*stmt_p), slot); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C b/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C new file mode 100644 index 00000000000..befac5f04b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C @@ -0,0 +1,25 @@ +// PR c++/107154 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-gno-as-loc-support -dA" } +// Test that we emit debug info exactly once for the last line. +// { dg-final { scan-assembler-times {:25:1} 1 } } + +bool dummy; + +struct S { + const char *p; + S(const char *p): p(p) {} + ~S() { dummy = true; } +}; + +using Sar = S[]; + +struct X { + X(Sar&&) { } +}; + +int main() +{ + X x(Sar{"", ""}); + return 0; +}