[PR c++/85634] Fix tsubst ICE
authorNathan Sidwell <nathan@acm.org>
Wed, 20 Jun 2018 19:22:53 +0000 (19:22 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 20 Jun 2018 19:22:53 +0000 (19:22 +0000)
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

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr85634-2.C [new file with mode: 0644]

index b567d60d129f51004cd6d430b3e75984c620637e..8dabe7624b3c5bfdada9f5348386b46679b9f92d 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-20  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/85634
+       * friend.c (add_friend): Keep lookup sets of tempate sets.
+
 2018-06-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * decl.c (grokfndecl): Add const cp_decl_specifier_seq* parameter;
index b31d4cfb72c466d637dc49476edd84bc1d31aa88..2c9c12fab4a9bf78ffbd2ce68870c0999efd6db1 100644 (file)
@@ -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);
index 800919666984ac4b6540a9cd2ff56fc4c8a903ec..271ac3de75009772efd11945524b69016fc1a59d 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-20  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/85634
+       * g++.dg/lookup/pr85634-2.C: New.
+
 2018-06-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * 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 (file)
index 0000000..f095ffc
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/85634
+
+namespace bsl {
+  template <class T> void frob (const T *);
+}
+
+using namespace bsl;
+
+template<class VALUE> void frob (const VALUE &);
+
+template <typename T>
+struct TPL {
+  friend void frob <T> (const T &);
+};
+
+TPL<int> x;