From 8aca5ebe07efd6d710c76eff2d3524f6c5c4ff2b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 21 Dec 2019 00:18:09 +0100 Subject: 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 --- gcc/cp/method.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/cp/method.c') diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 97c27c5..248a0e5 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1092,6 +1092,13 @@ early_check_defaulted_comparison (tree fn) ctx = DECL_FRIEND_CONTEXT (fn); 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) && !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node)) { -- cgit v1.1