diff options
author | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-02-16 14:30:55 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-02-16 14:30:55 +0000 |
commit | b1a7e33d67c9a3d4e7d390d28ae2f178861421cc (patch) | |
tree | 03a6da9299ca46f6483961a387a9c68f8801c730 | |
parent | 08223f7633e228cb4ab7a9125a50c4f8ce2e16bb (diff) | |
download | gcc-b1a7e33d67c9a3d4e7d390d28ae2f178861421cc.zip gcc-b1a7e33d67c9a3d4e7d390d28ae2f178861421cc.tar.gz gcc-b1a7e33d67c9a3d4e7d390d28ae2f178861421cc.tar.bz2 |
[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
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/pr84375.C | 9 |
4 files changed, 30 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ecd52d0..ee3ade9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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> PR c++/83227 - C++17 ICE with init-list derived-to-base conversion. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e5a3400..47cee30 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3079,12 +3079,16 @@ do_pushdecl (tree decl, bool is_friend) if (is_friend) { if (level->kind != sk_namespace) - /* In a local class, a friend function declaration must - find a matching decl in the innermost non-class scope. - [class.friend/11] */ - error ("friend declaration %qD in local class without " - "prior local declaration", decl); - else if (!flag_friend_injection) + { + /* In a local class, a friend function declaration must + find a matching decl in the innermost non-class scope. + [class.friend/11] */ + error ("friend declaration %qD in local class without " + "prior local declaration", decl); + /* Don't attempt to push it. */ + return error_mark_node; + } + if (!flag_friend_injection) /* Hide it from ordinary lookup. */ DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7cd64bb..58eb385 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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> PR target/83831 @@ -29,7 +34,7 @@ 2018-02-15 Martin Sebor <msebor@redhat.com> * gcc.dg/lto/README (dg-lto-warning, dg-lto-message): Document new - directives. + directives. 2018-02-15 Janus Weil <janus@gcc.gnu.org> diff --git a/gcc/testsuite/g++.dg/lookup/pr84375.C b/gcc/testsuite/g++.dg/lookup/pr84375.C new file mode 100644 index 0000000..24cdcb2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr84375.C @@ -0,0 +1,9 @@ +// PR c++/84375 ICE after error + +void foo() +{ + struct A + { + friend void A(); // { dg-error "local class without prior local" } + }; +} |