public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6419] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716] Date: Thu, 2 Mar 2023 18:19:03 +0000 (GMT) [thread overview] Message-ID: <20230302181903.4A6323858D33@sourceware.org> (raw) https://gcc.gnu.org/g:4d82022bfd15d36717bf60a11e75e9ea02204269 commit r13-6419-g4d82022bfd15d36717bf60a11e75e9ea02204269 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Mar 2 19:17:52 2023 +0100 c++, debug: Fix up locus of DW_TAG_imported_module [PR108716] Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that change we haven't emitted it at all for a while and after some time started emitting incorrect locus, in particular the location of } closing the function. The problem is that while we have correct EXPR_LOCATION on the USING_STMT, when genericizing that USING_STMT into IMPORTED_DECL we don't copy the location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens to be when it is created. 2023-03-02 Jakub Jelinek <jakub@redhat.com> PR debug/108716 * cp-gimplify.cc (cp_genericize_r) <case USING_STMT>: Set DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location of USING_STMT or input_location. * g++.dg/debug/dwarf2/pr108716.C: New test. Diff: --- gcc/cp/cp-gimplify.cc | 2 ++ gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index 32fe53521cc..921b0e4b120 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1530,6 +1530,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) tree using_directive = make_node (IMPORTED_DECL); TREE_TYPE (using_directive) = void_type_node; DECL_CONTEXT (using_directive) = current_function_decl; + DECL_SOURCE_LOCATION (using_directive) + = cp_expr_loc_or_input_loc (stmt); IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl; DECL_CHAIN (using_directive) = BLOCK_VARS (block); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C new file mode 100644 index 00000000000..59ed52424da --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C @@ -0,0 +1,14 @@ +// PR debug/108716 +// { dg-options "-O0 -gdwarf-5 -dA -fno-merge-debug-strings" } +// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*0xc\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*(\[^\n\r\]*0x13\[^\n\r\]* DW_AT_decl_column\[^\n\r\]*\[\n\r]*)?" } } + +namespace M { + int x = 1; +} + +int +main () +{ + using namespace M; + return 0; +}
reply other threads:[~2023-03-02 18:19 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=20230302181903.4A6323858D33@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).