[PR49366] emit loc exprs for C++ non-virtual pmf template value parms
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 12 Aug 2016 07:11:23 +0000 (07:11 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 12 Aug 2016 07:11:23 +0000 (07:11 +0000)
commit8aaf799b005461231d75f0889e3c78bd9b35eed9
tree737d04532927f66a28ff5e733a2d7ca27a390589
parentdf5b19dcc1a27395ba96503540ca0085ccaa7ef7
[PR49366] emit loc exprs for C++ non-virtual pmf template value parms

We used to emit, in debug information, the values bound to pointer to
member function template parameters only when they were NULL or
virtual member functions, because those can be represented with
DW_AT_const_value.

In order to represent the symbolic pointer to member function
constants for non-virtual member functions, we'd need to be able to
emit relocations for part of DW_AT_const_value, which we don't.  The
more viable alternative is to use DW_AT_location to represent such
values, as slated for inclusion in DWARFv5, according to
<URL:http://www.dwarfstd.org/ShowIssue.php?issue=130412.1>.

With this patch, when we can't emit a DW_AT_const_value, we emit each
"member" of the pointer to member function "record" as a
DW_OP_stack_value DW_OP_piece, as long as the referenced member
function is output in the same translation unit, otherwise we'd get
relocations to external symbols, something to avoid in debug sections.

for  gcc/ChangeLog

PR debug/49366
* dwarf2out.c (loc_list_from_tree_1): Expand some CONSTRUCTORs
in DW_OP_pieces, just enough to handle pointers to member
functions.
(gen_remaining_tmpl_value_param_die_attribute): Use a location
expression on DWARFv5 if a constant value doesn't work.

for  gcc/testsuite/ChangeLog

PR debug/49366
* g++.dg/debug/dwarf2/template-params-12.H: New.
* g++.dg/debug/dwarf2/template-params-12f.C: New.
* g++.dg/debug/dwarf2/template-params-12g.C: New.
* g++.dg/debug/dwarf2/template-params-12n.C: New.
* g++.dg/debug/dwarf2/template-params-12s.C: New.
* g++.dg/debug/dwarf2/template-params-12u.C: New.
* g++.dg/debug/dwarf2/template-params-12v.C: New.
* g++.dg/debug/dwarf2/template-params-12w.C: New.

From-SVN: r239401
gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12.H [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12f.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12g.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12n.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12s.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12u.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12v.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/template-params-12w.C [new file with mode: 0644]