The extern template __shared_ptr<filesystem::_Dir> in bits/fs_dir.h was
leading to an ICE in import_export_decl in 29_atomics/atomic_ref/address.cc
because we had the nonsensical combination of DECL_REALLY_EXTERN and
!DECL_INTERFACE_KNOWN. This turned out to be because mark_decl_instantiated
was exiting early if TREE_ASM_WRITTEN since way back in the pre-cgraph days,
and expand_or_defer_fn_1 sets TREE_ASM_WRITTEN on maybe-in-charge ctors.
The mark_decl_instantiated code is long-obsolete, so let's just remove it.
gcc/cp/ChangeLog:
* module.cc (trees_out::write_function_def): Check flag consistency.
* pt.cc (mark_decl_instantiated): Ignore TREE_ASM_WRITTEN.
&& (get_importer_interface (decl)
!= importer_interface::external));
+ /* Make sure DECL_REALLY_EXTERN and DECL_INTERFACE_KNOWN are consistent
+ on non-templates or we'll crash later in import_export_decl. */
+ gcc_checking_assert (flags || DECL_INTERFACE_KNOWN (decl)
+ || (DECL_LANG_SPECIFIC (decl)
+ && DECL_TEMPLATE_INFO (decl)
+ && uses_template_parms (DECL_TI_ARGS (decl))));
+
if (f)
{
flags |= 2;
{
SET_DECL_EXPLICIT_INSTANTIATION (result);
- /* If this entity has already been written out, it's too late to
- make any modifications. */
- if (TREE_ASM_WRITTEN (result))
- return;
-
/* consteval functions are never emitted. */
if (TREE_CODE (result) == FUNCTION_DECL
&& DECL_IMMEDIATE_FUNCTION_P (result))