https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79061
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Comment on attachment 40514 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40514 Untested fix 1. But DECL_SOURCE_FILE is not the main input file of the TU that contains it, if e.g. a variable is defined in a header. Can't you find the corresponding TRANSLATION_UNIT_DECL (see e.g. how dwarf2out.c is_cxx now looks for that) and get the name from that? And, the multiple ?s look just weird, (in_lto_p && something ? something : main_input_filename); would be nicer.