if (TREE_CODE (decl) == CONST_DECL)
used_types_insert (DECL_CONTEXT (decl));
- if (TREE_CODE (decl) == FUNCTION_DECL
- && !DECL_DELETED_FN (decl)
- && !maybe_instantiate_noexcept (decl, complain))
- return false;
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ if (DECL_MAYBE_DELETED (decl))
+ {
+ ++function_depth;
+ maybe_synthesize_method (decl);
+ --function_depth;
+ }
- if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_DELETED_FN (decl))
- {
- if (DECL_ARTIFICIAL (decl)
- && DECL_CONV_FN_P (decl)
- && LAMBDA_TYPE_P (DECL_CONTEXT (decl)))
- /* We mark a lambda conversion op as deleted if we can't
- generate it properly; see maybe_add_lambda_conv_op. */
- sorry ("converting lambda that uses %<...%> to function pointer");
- else if (complain & tf_error)
+ if (DECL_DELETED_FN (decl))
{
- error ("use of deleted function %qD", decl);
- if (!maybe_explain_implicit_delete (decl))
- inform (DECL_SOURCE_LOCATION (decl), "declared here");
+ if (DECL_ARTIFICIAL (decl)
+ && DECL_CONV_FN_P (decl)
+ && LAMBDA_TYPE_P (DECL_CONTEXT (decl)))
+ /* We mark a lambda conversion op as deleted if we can't
+ generate it properly; see maybe_add_lambda_conv_op. */
+ sorry ("converting lambda that uses %<...%> to function pointer");
+ else if (complain & tf_error)
+ {
+ error ("use of deleted function %qD", decl);
+ if (!maybe_explain_implicit_delete (decl))
+ inform (DECL_SOURCE_LOCATION (decl), "declared here");
+ }
+ return false;
}
- return false;
+
+ if (!maybe_instantiate_noexcept (decl, complain))
+ return false;
}
if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_LOCAL_DECL_P (decl))
&& (!flag_noexcept_type || type_dependent_expression_p (fn)))
return true;
- if (DECL_MAYBE_DELETED (fn))
+ tree fntype = TREE_TYPE (fn);
+ tree spec = TYPE_RAISES_EXCEPTIONS (fntype);
+
+ if ((!spec || UNEVALUATED_NOEXCEPT_SPEC_P (spec))
+ && DECL_MAYBE_DELETED (fn))
{
if (fn == current_function_decl)
/* We're in start_preparsed_function, keep going. */
++function_depth;
maybe_synthesize_method (fn);
--function_depth;
- return !DECL_MAYBE_DELETED (fn);
+ return !DECL_DELETED_FN (fn);
}
- tree fntype = TREE_TYPE (fn);
- tree spec = TYPE_RAISES_EXCEPTIONS (fntype);
-
if (!spec || !TREE_PURPOSE (spec))
return true;
--- /dev/null
+// PR c++/96242
+// { dg-do compile { target c++20 } }
+
+#include <compare>
+
+template<bool B>
+struct X {
+ auto operator<=>(const X&) const noexcept(B) = default;
+ bool operator==(const X&) const noexcept(!B) = default;
+};
+
+X<true> x_t;
+static_assert(noexcept(x_t <=> x_t));
+static_assert(noexcept(x_t < x_t));
+static_assert(!noexcept(x_t == x_t));
+static_assert(!noexcept(x_t != x_t));
+
+X<false> x_f;
+static_assert(!noexcept(x_f <=> x_f));
+static_assert(!noexcept(x_f < x_f));
+static_assert(noexcept(x_f == x_f));
+static_assert(noexcept(x_f != x_f));