From: Nathan Sidwell Date: Wed, 20 Jun 2018 19:22:53 +0000 (+0000) Subject: [PR c++/85634] Fix tsubst ICE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1456656842bef093d73e1f324eb49b94db87203;p=gcc.git [PR c++/85634] Fix tsubst ICE https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01274.html PR c++/85634 * friend.c (add_friend): Keep lookup sets of tempate sets. PR c++/85634 * g++.dg/lookup/pr85634-2.C: New. From-SVN: r261817 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b567d60d129..8dabe7624b3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-06-20 Nathan Sidwell + + PR c++/85634 + * friend.c (add_friend): Keep lookup sets of tempate sets. + 2018-06-20 Paolo Carlini * decl.c (grokfndecl): Add const cp_decl_specifier_seq* parameter; diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index b31d4cfb72c..2c9c12fab4a 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -173,6 +173,12 @@ add_friend (tree type, tree decl, bool complain) if (decl == error_mark_node) return; + if (TREE_CODE (decl) == FUNCTION_DECL + && DECL_TEMPLATE_INSTANTIATION (decl)) + /* We'll have parsed this as a declaration, and therefore not + marked the lookup set for keeping. Do that now. */ + lookup_keep (DECL_TI_TEMPLATE (decl)); + typedecl = TYPE_MAIN_DECL (type); list = DECL_FRIENDLIST (typedecl); name = DECL_NAME (decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80091966698..271ac3de750 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-20 Nathan Sidwell + + PR c++/85634 + * g++.dg/lookup/pr85634-2.C: New. + 2018-06-20 Paolo Carlini * g++.dg/template/friend65.C: New. diff --git a/gcc/testsuite/g++.dg/lookup/pr85634-2.C b/gcc/testsuite/g++.dg/lookup/pr85634-2.C new file mode 100644 index 00000000000..f095ffc82af --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr85634-2.C @@ -0,0 +1,16 @@ +// PR c++/85634 + +namespace bsl { + template void frob (const T *); +} + +using namespace bsl; + +template void frob (const VALUE &); + +template +struct TPL { + friend void frob (const T &); +}; + +TPL x;