inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888]
authorJakub Jelinek <jakub@redhat.com>
Wed, 4 Mar 2020 11:59:04 +0000 (12:59 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 4 Mar 2020 11:59:04 +0000 (12:59 +0100)
commit64ba6d17022eeb65f56f0b141c2640f9ab938f97
tree0c1fd44a3b5ba8341466c911d0a924dc07d53a1f
parent1cdfb80a4ec7b6585b436917e13b205055732232
inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888]

In the following testcase we emit wrong debug info for the karg
parameter in the DW_TAG_inlined_subroutine into main.
The problem is that the karg PARM_DECL is DECL_BY_REFERENCE and thus
in the IL has const K & type, but in the source just const K.
When the function is inlined, we create a VAR_DECL for it, but don't
set DECL_BY_REFERENCE, so when emitting DW_AT_location, we treat it like
a const K & typed variable, but it has DW_AT_abstract_origin which has
just the const K type and thus the debugger thinks the variable has
const K type.

Fixed by copying the DECL_BY_REFERENCE flag.  Not doing it in
copy_decl_for_dup_finish, because copy_decl_no_change already copies
that flag through copy_node and in copy_result_decl_to_var it is
undesirable, as we handle DECL_BY_REFERENCE in that case instead
by changing the type.

2020-03-04  Jakub Jelinek  <jakub@redhat.com>

PR debug/93888
* tree-inline.c (copy_decl_to_var): Copy DECL_BY_REFERENCE flag.

* g++.dg/guality/pr93888.C: New test.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/guality/pr93888.C [new file with mode: 0644]
gcc/tree-inline.c