From: Jason Merrill <jason@redhat.com>
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 [thread overview]
Message-ID: <20221004225229.3104706-1-jason@redhat.com> (raw)
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
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;
+}
base-commit: 49c3e9dfc5e23a335f4057efffbff2273e3c4631
--
2.31.1
reply other threads:[~2022-10-04 22:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221004225229.3104706-1-jason@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).