]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: explicit inst of constructor
authorJason Merrill <jason@redhat.com>
Sat, 15 Nov 2025 17:43:37 +0000 (23:13 +0530)
committerJason Merrill <jason@redhat.com>
Sat, 15 Nov 2025 17:43:37 +0000 (23:13 +0530)
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.

gcc/cp/module.cc
gcc/cp/pt.cc

index 45a0309b86e6ea4340762d54f5069d70092afc5f..48ee7d1e790474354fbdb03ae8ed10634743fe9a 100644 (file)
@@ -12914,6 +12914,13 @@ trees_out::write_function_def (tree decl)
                    && (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;
index b10442b09609c8c1b2a0464123e87371d2ece53c..3b581b3fd36939bec5049b12d8f2d0733e3ad1de 100644 (file)
@@ -26379,11 +26379,6 @@ mark_decl_instantiated (tree result, int extern_p)
 {
   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))