https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82204
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- --- gcc/cp/decl2.c.jj 2018-06-29 09:38:17.788306397 +0200 +++ gcc/cp/decl2.c 2018-06-30 09:54:59.516868946 +0200 @@ -5312,6 +5312,20 @@ mark_used (tree decl, tsubst_flags_t com if (DECL_ODR_USED (decl)) return true; + /* If decl is local extern, recurse into corresponding decl. */ + if (cfun + && cp_function_chain + && cp_function_chain->extern_decl_map + && VAR_OR_FUNCTION_DECL_P (decl) + && DECL_EXTERNAL (decl)) + { + struct cxx_int_tree_map *h, in; + in.uid = DECL_UID (decl); + h = cp_function_chain->extern_decl_map->find_with_hash (&in, in.uid); + if (h && !mark_used (h->to)) + return false; + } + /* Normally, we can wait until instantiation-time to synthesize DECL. However, if DECL is a static data member initialized with a constant or a constexpr function, we need it right now because a reference to that helps with PR3698 doesn't help here.