The following fixes PR71057 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard. 2016-05-11 Richard Biener <rguent...@suse.de> PR debug/71057 * dwarf2out.c (retry_incomplete_types): Set early_dwarf. (dwarf2out_finish): Move retry_incomplete_types call ... (dwarf2out_early_finish): ... here. * g++.dg/debug/pr71057.C: New testcase. Index: gcc/dwarf2out.c =================================================================== *** gcc/dwarf2out.c (revision 236032) --- gcc/dwarf2out.c (working copy) *************** gen_entry_point_die (tree decl, dw_die_r *** 19401,19411 **** --- 19401,19413 ---- static void retry_incomplete_types (void) { + set_early_dwarf s; int i; for (i = vec_safe_length (incomplete_types) - 1; i >= 0; i--) if (should_emit_struct_debug ((*incomplete_types)[i], DINFO_USAGE_DIR_USE)) gen_type_die ((*incomplete_types)[i], comp_unit_die ()); + vec_safe_truncate (incomplete_types, 0); } /* Determine what tag to use for a record type. */ *************** dwarf2out_finish (const char *filename) *** 27382,27391 **** resolve_addr (comp_unit_die ()); move_marked_base_types (); - /* Walk through the list of incomplete types again, trying once more to - emit full debugging info for them. */ - retry_incomplete_types (); - if (flag_eliminate_unused_debug_types) prune_unused_types (); --- 27384,27389 ---- *************** dwarf2out_finish (const char *filename) *** 27686,27691 **** --- 27684,27693 ---- static void dwarf2out_early_finish (void) { + /* Walk through the list of incomplete types again, trying once more to + emit full debugging info for them. */ + retry_incomplete_types (); + /* The point here is to flush out the limbo list so that it is empty and we don't need to stream it for LTO. */ flush_limbo_die_list (); Index: gcc/testsuite/g++.dg/debug/pr71057.C =================================================================== *** gcc/testsuite/g++.dg/debug/pr71057.C (revision 0) --- gcc/testsuite/g++.dg/debug/pr71057.C (working copy) *************** *** 0 **** --- 1,12 ---- + // { dg-do compile } + // { dg-options "-g" } + template <typename _Tp> using decay_t = _Tp; + template <typename> struct A; + template <typename> struct B { B(A<int>); }; + template <typename> struct C { + template <typename U> using constructor = B<decay_t<U>>; + typedef constructor<int> dummy; + }; + template <typename> struct D {}; + C<int> a; + D<B<int>> fn1() { fn1, a; }