Commit 467fc7c8 by Jason Merrill

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.
parent 93a49d2d
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> 2020-04-04 Marek Polacek <polacek@redhat.com>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
......
...@@ -1451,9 +1451,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1451,9 +1451,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* Check for redeclaration and other discrepancies. */ /* Check for redeclaration and other discrepancies. */
if (TREE_CODE (olddecl) == FUNCTION_DECL 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) if (TREE_CODE (newdecl) != FUNCTION_DECL)
{ {
/* Avoid warnings redeclaring built-ins which have not been /* Avoid warnings redeclaring built-ins which have not been
......
// 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);
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment