aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/method.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-02-05 19:56:45 -0500
committerJason Merrill <jason@redhat.com>2024-02-05 21:29:43 -0500
commitc5d34912ad576be1ef19be92f7eabde54b9089eb (patch)
tree223d85153cb925b56b887a7997a8d916ee6f6463 /gcc/cp/method.cc
parent66eebab468045fcb3a8eedcfcc6756ad46aef3b8 (diff)
downloadgcc-c5d34912ad576be1ef19be92f7eabde54b9089eb.zip
gcc-c5d34912ad576be1ef19be92f7eabde54b9089eb.tar.gz
gcc-c5d34912ad576be1ef19be92f7eabde54b9089eb.tar.bz2
c++: defaulted op== for incomplete class [PR107291]
After complaining about lack of friendship, we should not try to go on and define the defaulted comparison operator anyway. PR c++/107291 gcc/cp/ChangeLog: * method.cc (early_check_defaulted_comparison): Fail if not friend. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-eq17.C: New test.
Diffstat (limited to 'gcc/cp/method.cc')
-rw-r--r--gcc/cp/method.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index d49e5a5..3b8dc75 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -1228,7 +1228,11 @@ early_check_defaulted_comparison (tree fn)
/* Defaulted outside the class body. */
ctx = TYPE_MAIN_VARIANT (parmtype);
if (!is_friend (ctx, fn))
- error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx);
+ {
+ error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx);
+ inform (location_of (ctx), "declared here");
+ ok = false;
+ }
}
else if (!same_type_ignoring_top_level_qualifiers_p (parmtype, ctx))
saw_bad = true;