From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id DA86C3858C50; Tue, 4 Oct 2022 22:54:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA86C3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664924051; bh=/1jyLoWUQCp7tiaVVvM6SPYZGPxeKo0k0yR62tIdfjU=; h=From:To:Subject:Date:From; b=Sk+i++wuMS6uDP3BGOa1fUas+4167B+C0HlgsgZWXZh4z6hRdD+iW2/ttDTOQy2/P ruMNFhNMeTetzFQaP7TkY0BxR5XlO4artFuf6SfOloJOSGqd29UEsbYhcq/Ghwn4FK RiP3F4c8x/nbcuiZ8fuXIlChc6DdLTUYJwgldXy8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3072] c++: fix debug info for array temporary [PR107154] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: 0764dc8537a4f87089ecd32391cb5f8803b43c96 X-Git-Newrev: ce3a1b5976079b1467473b4628f05797fd2eae08 Message-Id: <20221004225411.DA86C3858C50@sourceware.org> Date: Tue, 4 Oct 2022 22:54:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ce3a1b5976079b1467473b4628f05797fd2eae08 commit r13-3072-gce3a1b5976079b1467473b4628f05797fd2eae08 Author: Jason Merrill Date: Tue Oct 4 17:06:04 2022 -0400 c++: fix debug info for array temporary [PR107154] 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. Diff: --- gcc/cp/cp-gimplify.cc | 2 ++ gcc/testsuite/g++.dg/debug/dwarf2/lineno-array1.C | 25 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) 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; +}