re PR c++/92966 (Segfault on defaulted operator== with wrong return type)
PR c++/92966 * method.c (early_check_defaulted_comparison): Don't set DECL_MAYBE_DELETED when returning false. * g++.dg/cpp2a/spaceship-eq8.C: New test. From-SVN: r279683
This commit is contained in:
parent
8aca5ebe07
commit
b804bd89d3
@ -1,5 +1,9 @@
|
||||
2019-12-20 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/92966
|
||||
* method.c (early_check_defaulted_comparison): Don't set
|
||||
DECL_MAYBE_DELETED when returning false.
|
||||
|
||||
PR c++/92973
|
||||
* method.c (early_check_defaulted_comparison): For C++17 and earlier
|
||||
diagnose defaulted comparison operators.
|
||||
|
@ -1153,7 +1153,7 @@ early_check_defaulted_comparison (tree fn)
|
||||
}
|
||||
|
||||
/* We still need to deduce deleted/constexpr/noexcept and maybe return. */
|
||||
DECL_MAYBE_DELETED (fn) = true;
|
||||
DECL_MAYBE_DELETED (fn) = ok;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
2019-12-20 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/92966
|
||||
* g++.dg/cpp2a/spaceship-eq8.C: New test.
|
||||
|
||||
PR c++/92973
|
||||
* g++.dg/cpp0x/spaceship-eq1.C: New test.
|
||||
|
||||
|
8
gcc/testsuite/g++.dg/cpp2a/spaceship-eq8.C
Normal file
8
gcc/testsuite/g++.dg/cpp2a/spaceship-eq8.C
Normal file
@ -0,0 +1,8 @@
|
||||
// PR c++/92966
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
struct S {
|
||||
int operator==(const S&) const = default; // { dg-error "must return 'bool'" }
|
||||
int s; // { dg-message "declared here" "" { target *-*-* } .-1 }
|
||||
};
|
||||
static_assert(S{} == S{}); // { dg-error "" }
|
Loading…
Reference in New Issue
Block a user