]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: -fimplicit-constexpr and modules
authorJason Merrill <jason@redhat.com>
Fri, 9 May 2025 23:13:49 +0000 (19:13 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 15 May 2025 14:31:47 +0000 (10:31 -0400)
Import didn't like differences in DECL_DECLARED_CONSTEXPR_P due to implicit
constexpr, breaking several g++.dg/modules tests; we should handle that
along with DECL_MAYBE_DELETED.  For which we need to stream the bit.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_decl_bools): Stream implicit_constexpr.
(trees_in::lang_decl_bools): Likewise.
(trees_in::is_matching_decl): Check it.

gcc/cp/module.cc

index e7782627a492e692d0745f30169eea9bbc5c0d62..4f9c3788380a9d34ae86fcb1b8f36d7159b507e9 100644 (file)
@@ -6024,7 +6024,7 @@ trees_out::lang_decl_bools (tree t, bits_out& bits)
       WB (lang->u.fn.has_dependent_explicit_spec_p);
       WB (lang->u.fn.immediate_fn_p);
       WB (lang->u.fn.maybe_deleted);
-      /* We do not stream lang->u.fn.implicit_constexpr.  */
+      WB (lang->u.fn.implicit_constexpr);
       WB (lang->u.fn.escalated_p);
       WB (lang->u.fn.xobj_func);
       goto lds_min;
@@ -6095,7 +6095,7 @@ trees_in::lang_decl_bools (tree t, bits_in& bits)
       RB (lang->u.fn.has_dependent_explicit_spec_p);
       RB (lang->u.fn.immediate_fn_p);
       RB (lang->u.fn.maybe_deleted);
-      /* We do not stream lang->u.fn.implicit_constexpr.  */
+      RB (lang->u.fn.implicit_constexpr);
       RB (lang->u.fn.escalated_p);
       RB (lang->u.fn.xobj_func);
       goto lds_min;
@@ -12193,13 +12193,23 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)
 
       /* Similarly if EXISTING has undeduced constexpr, but DECL's
         is already deduced.  */
-      if (DECL_MAYBE_DELETED (e_inner) && !DECL_MAYBE_DELETED (d_inner)
-         && DECL_DECLARED_CONSTEXPR_P (d_inner))
-       DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
-      else if (!DECL_MAYBE_DELETED (e_inner) && DECL_MAYBE_DELETED (d_inner))
-       /* Nothing to do.  */;
+      if (DECL_DECLARED_CONSTEXPR_P (e_inner)
+         == DECL_DECLARED_CONSTEXPR_P (d_inner))
+       /* Already matches.  */;
+      else if (DECL_DECLARED_CONSTEXPR_P (d_inner)
+              && (DECL_MAYBE_DELETED (e_inner)
+                  || decl_implicit_constexpr_p (d_inner)))
+       /* DECL was deduced, copy to EXISTING.  */
+       {
+         DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
+         if (decl_implicit_constexpr_p (d_inner))
+           DECL_LANG_SPECIFIC (e_inner)->u.fn.implicit_constexpr = true;
+       }
       else if (DECL_DECLARED_CONSTEXPR_P (e_inner)
-              != DECL_DECLARED_CONSTEXPR_P (d_inner))
+              && (DECL_MAYBE_DELETED (d_inner)
+                  || decl_implicit_constexpr_p (e_inner)))
+       /* EXISTING was deduced, leave it alone.  */;
+      else
        {
          mismatch_msg = G_("conflicting %<constexpr%> for imported "
                            "declaration %#qD");