On 4/10/25 8:46 AM, Nathaniel Shead wrote:
Regression raised with my by private correspondance.
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?

-- >8 --

My change in r15-9216 broke the case where we imported an uninstantiated
defaulted function over the top of one we had already finished.  This
patch ensures that we don't error for mismatches when either function
has mismatching deferral from the other.

These changes seem to mean that importing a deferred decl can overwrite properties of an existing non-deferred one.

To assist in understanding these errors in the future as well, I've
customised the mismatch message for different cases.  I also rephrased
the message to talk about "imported declarations" rather than "global
module declarations", since as the FIXME noted we can also get
mismatches with some declarations attached to modules.  Ideally I'd like
to revisit the way this is structured entirely but that won't be
appropriate for GCC 15.

Please split these changes into a separate commit; that patch is OK.

@@ -12125,7 +12142,8 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
         instantiate it in the middle of loading.   */
        tree e_spec = TYPE_RAISES_EXCEPTIONS (e_type);
        tree d_spec = TYPE_RAISES_EXCEPTIONS (d_type);
-      if (DECL_MAYBE_DELETED (e_inner) || DEFERRED_NOEXCEPT_SPEC_P (e_spec))
+      if (DEFERRED_NOEXCEPT_SPEC_P (e_spec)
+         || DECL_MAYBE_DELETED (d_inner) != DECL_MAYBE_DELETED (e_inner))
        {
          if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)

If loading a DECL_MAYBE_DELETED decl, I think it will have no eh spec, so DEFERRED_NOEXCEPT_SPEC_P will be false, so this will now propagate the lack of eh spec to the existing decl.

        /* 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;
+      if (DECL_MAYBE_DELETED (e_inner) != DECL_MAYBE_DELETED (d_inner))
+       {
+         if (DECL_DECLARED_CONSTEXPR_P (d_inner))
+           DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
+       }

And similarly if decl is MAYBE_DELETED, we will copy its constexpr. Though I guess only if it's declared constexpr, which is unlikely to cause trouble. But still, rather than change these two conditions to != I'd rather add an else for the reverse mismatch that probably just accepts the difference.

Jason

Reply via email to