aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2025-04-11 07:29:11 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2025-04-13 20:33:38 +1000
commitf40e39515e0b7fa69bd50bad99f1f1b8c446692f (patch)
treecbf5be2192e4abb1ea35cc05fd2c3a425fbb2940
parent714e9020becc260a05f17ae694a6bdde65d9c567 (diff)
downloadgcc-f40e39515e0b7fa69bd50bad99f1f1b8c446692f.zip
gcc-f40e39515e0b7fa69bd50bad99f1f1b8c446692f.tar.gz
gcc-f40e39515e0b7fa69bd50bad99f1f1b8c446692f.tar.bz2
c++/modules: More fixes for merging DECL_MAYBE_DELETED functions
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 in this case. gcc/cp/ChangeLog: * module.cc (trees_in::is_matching_decl): Don't check for mismatches when importing a DECL_MAYBE_DELETED function over one that's already finished. gcc/testsuite/ChangeLog: * g++.dg/modules/noexcept-4_a.H: New test. * g++.dg/modules/noexcept-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
-rw-r--r--gcc/cp/module.cc5
-rw-r--r--gcc/testsuite/g++.dg/modules/noexcept-4_a.H6
-rw-r--r--gcc/testsuite/g++.dg/modules/noexcept-4_b.C18
3 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 8efa18b..5ff5c46 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12164,7 +12164,8 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)
}
}
}
- else if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)
+ else if (!DECL_MAYBE_DELETED (d_inner)
+ && !DEFERRED_NOEXCEPT_SPEC_P (d_spec)
&& !comp_except_specs (d_spec, e_spec, ce_type))
{
mismatch_msg = G_("conflicting %<noexcept%> specifier for "
@@ -12195,6 +12196,8 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)
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. */;
else if (DECL_DECLARED_CONSTEXPR_P (e_inner)
!= DECL_DECLARED_CONSTEXPR_P (d_inner))
{
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_a.H b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
new file mode 100644
index 0000000..b888a1b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodule-header -std=c++20" }
+// { dg-module-cmi {} }
+
+struct exception_ptr {
+ friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_b.C b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
new file mode 100644
index 0000000..7cc5531
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
@@ -0,0 +1,18 @@
+// { dg-additional-options "-fmodules -std=c++20" }
+
+struct exception_ptr {
+ friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
+
+void enqueue() {
+ exception_ptr e;
+ e == e;
+}
+
+import "noexcept-4_a.H";
+
+int main() {
+ constexpr exception_ptr e;
+ static_assert(e == e);
+ static_assert(noexcept(e == e));
+}