Commit b1a7e33d by Nathan Sidwell

[PR c++/84375] Fix ICE after bad friend

https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00987.html
	PR c++/84375
	* name-lookup.c (do_pushdecl): Bail out on bad local friend injection.

	* g++.dg/lookup/pr84375.C: New.

From-SVN: r257739
parent 08223f76
2018-02-16 Nathan Sidwell <nathan@acm.org>
PR c++/84375
* name-lookup.c (do_pushdecl): Bail out on bad local friend injection.
2018-02-15 Jason Merrill <jason@redhat.com> 2018-02-15 Jason Merrill <jason@redhat.com>
PR c++/83227 - C++17 ICE with init-list derived-to-base conversion. PR c++/83227 - C++17 ICE with init-list derived-to-base conversion.
......
...@@ -3079,12 +3079,16 @@ do_pushdecl (tree decl, bool is_friend) ...@@ -3079,12 +3079,16 @@ do_pushdecl (tree decl, bool is_friend)
if (is_friend) if (is_friend)
{ {
if (level->kind != sk_namespace) if (level->kind != sk_namespace)
/* In a local class, a friend function declaration must {
find a matching decl in the innermost non-class scope. /* In a local class, a friend function declaration must
[class.friend/11] */ find a matching decl in the innermost non-class scope.
error ("friend declaration %qD in local class without " [class.friend/11] */
"prior local declaration", decl); error ("friend declaration %qD in local class without "
else if (!flag_friend_injection) "prior local declaration", decl);
/* Don't attempt to push it. */
return error_mark_node;
}
if (!flag_friend_injection)
/* Hide it from ordinary lookup. */ /* Hide it from ordinary lookup. */
DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true; DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true;
} }
......
2018-02-16 Nathan Sidwell <nathan@acm.org>
PR c++/84375
* g++.dg/lookup/pr84375.C: New.
2018-02-14 Oleg Endo <olegendo@gcc.gnu.org> 2018-02-14 Oleg Endo <olegendo@gcc.gnu.org>
PR target/83831 PR target/83831
...@@ -29,7 +34,7 @@ ...@@ -29,7 +34,7 @@
2018-02-15 Martin Sebor <msebor@redhat.com> 2018-02-15 Martin Sebor <msebor@redhat.com>
* gcc.dg/lto/README (dg-lto-warning, dg-lto-message): Document new * gcc.dg/lto/README (dg-lto-warning, dg-lto-message): Document new
directives. directives.
2018-02-15 Janus Weil <janus@gcc.gnu.org> 2018-02-15 Janus Weil <janus@gcc.gnu.org>
......
// PR c++/84375 ICE after error
void foo()
{
struct A
{
friend void A(); // { dg-error "local class without prior local" }
};
}
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