aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-12-21 00:18:09 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-12-21 00:18:09 +0100
commit8aca5ebe07efd6d710c76eff2d3524f6c5c4ff2b (patch)
tree5533bc6d04286960b1ff1db034ed9fd86491b024 /gcc/cp
parent0bd002bf2e9f0224905ad19f036dde27b63c26c5 (diff)
downloadgcc-8aca5ebe07efd6d710c76eff2d3524f6c5c4ff2b.zip
gcc-8aca5ebe07efd6d710c76eff2d3524f6c5c4ff2b.tar.gz
gcc-8aca5ebe07efd6d710c76eff2d3524f6c5c4ff2b.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/method.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5a9a648..07200ad 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
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
* call.c (convert_arg_to_ellipsis): For floating point or
decltype(nullptr) arguments call mark_rvalue_use.
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))
{