c++: Fix ICE with implicit operator== [PR94462]
duplicate_decls assumed that any TREE_ARTIFICIAL function at namespace scope was a built-in function, but now in C++20 it's possible to have an implicitly declared hidden friend operator==. We just need to move the assert into the if condition. gcc/cp/ChangeLog 2020-04-06 Jason Merrill <jason@redhat.com> PR c++/94462 * decl.c (duplicate_decls): Fix handling of DECL_HIDDEN_FRIEND_P.
This commit is contained in:
parent
93a49d2d22
commit
467fc7c83a
3 changed files with 25 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2020-04-06 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/94462
|
||||
* decl.c (duplicate_decls): Fix handling of DECL_HIDDEN_FRIEND_P.
|
||||
|
||||
2020-04-04 Marek Polacek <polacek@redhat.com>
|
||||
Jason Merrill <jason@redhat.com>
|
||||
|
||||
|
|
|
@ -1451,9 +1451,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
|
|||
|
||||
/* Check for redeclaration and other discrepancies. */
|
||||
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
||||
&& DECL_ARTIFICIAL (olddecl))
|
||||
&& DECL_ARTIFICIAL (olddecl)
|
||||
/* A C++20 implicit friend operator== uses the normal path (94462). */
|
||||
&& !DECL_HIDDEN_FRIEND_P (olddecl))
|
||||
{
|
||||
gcc_assert (!DECL_HIDDEN_FRIEND_P (olddecl));
|
||||
if (TREE_CODE (newdecl) != FUNCTION_DECL)
|
||||
{
|
||||
/* Avoid warnings redeclaring built-ins which have not been
|
||||
|
|
17
gcc/testsuite/g++.dg/cpp2a/spaceship-eq9.C
Normal file
17
gcc/testsuite/g++.dg/cpp2a/spaceship-eq9.C
Normal file
|
@ -0,0 +1,17 @@
|
|||
// PR c++/94462
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
namespace std {
|
||||
struct strong_ordering { };
|
||||
}
|
||||
|
||||
namespace Synth {
|
||||
struct B {
|
||||
friend std::strong_ordering operator<=>(B, B) = default;
|
||||
};
|
||||
|
||||
struct C {
|
||||
friend bool operator==(C, C);
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue