debug/107058 - gracefully handle unexpected DIE contexts
commite2f3057fc911f9f55986b3de237b0155c0e09fe8
authorRichard Biener <rguenther@suse.de>
Tue, 23 Jan 2024 08:51:00 +0000 (23 09:51 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 23 Jan 2024 10:15:29 +0000 (23 11:15 +0100)
tree48db71546280e6062a82bcd324225d1df1e1407d
parentaffef534b0335592336c82918f15242576e2ab8f
debug/107058 - gracefully handle unexpected DIE contexts

While the bug is persisting that LTO streaming picks up a CONST_DECL
from an attribute argument on a VAR_DECL which with -fdebug-type-section
refers to a DIE in a type unit we can handle this gracefully, at least
with -fno-checking.  Do so.  The C++ frontend nevetheless should resolve
the CONST_DECL attribute argument to a constant.

PR debug/107058
* dwarf2out.cc (dwarf2out_die_ref_for_decl): Gracefully
handle unexpected but bogus DIE contexts when not checking
enabled.

* c-c++-common/pr107058.c: New testcase.
gcc/dwarf2out.cc
gcc/testsuite/c-c++-common/pr107058.c [new file with mode: 0644]