Commit 8aca5ebe by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/92973 (Silently accepting defaulted comparison operators in C++11 .. 17)

	PR c++/92973
	* method.c (early_check_defaulted_comparison): For C++17 and earlier
	diagnose defaulted comparison operators.

	* g++.dg/cpp0x/spaceship-eq1.C: New test.

From-SVN: r279682
parent 0bd002bf
2019-12-20 Jakub Jelinek <jakub@redhat.com> 2019-12-20 Jakub Jelinek <jakub@redhat.com>
PR c++/92973
* method.c (early_check_defaulted_comparison): For C++17 and earlier
diagnose defaulted comparison operators.
PR c++/92666 PR c++/92666
* call.c (convert_arg_to_ellipsis): For floating point or * call.c (convert_arg_to_ellipsis): For floating point or
decltype(nullptr) arguments call mark_rvalue_use. decltype(nullptr) arguments call mark_rvalue_use.
......
...@@ -1092,6 +1092,13 @@ early_check_defaulted_comparison (tree fn) ...@@ -1092,6 +1092,13 @@ early_check_defaulted_comparison (tree fn)
ctx = DECL_FRIEND_CONTEXT (fn); ctx = DECL_FRIEND_CONTEXT (fn);
bool ok = true; bool ok = true;
if (cxx_dialect < cxx2a)
{
error_at (loc, "defaulted %qD only available with %<-std=c++2a%> or "
"%<-std=gnu++2a%>", fn);
return false;
}
if (!DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR) if (!DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR)
&& !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node)) && !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node))
{ {
......
2019-12-20 Jakub Jelinek <jakub@redhat.com> 2019-12-20 Jakub Jelinek <jakub@redhat.com>
PR c++/92973
* g++.dg/cpp0x/spaceship-eq1.C: New test.
PR c++/92666 PR c++/92666
* g++.dg/warn/Wunused-var-36.C: New test. * g++.dg/warn/Wunused-var-36.C: New test.
......
// PR c++/92973
// { dg-do compile { target c++11 } }
struct S { bool operator==(const S&) const = default; int s; }; // { dg-error "only available with" "" { target c++17_down } }
struct T { bool operator!=(const T&) const = default; int t; }; // { dg-error "only available with" "" { target c++17_down } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment