[PR c++/84694] ICE on template friend decl
authorNathan Sidwell <nathan@acm.org>
Mon, 5 Mar 2018 16:12:07 +0000 (16:12 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 5 Mar 2018 16:12:07 +0000 (16:12 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00221.html
PR c++/84694
* friend.c (do_friend): Restore check for identifier_p inside
TEMPLATE_ID_EXPR.

PR c++/84694
* g++.dg/template/pr84694.C: New.

From-SVN: r258254

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr84694.C [new file with mode: 0644]

index 5e16635..6c37dc3 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-05  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84694
+       * friend.c (do_friend): Restore check for identifier_p inside
+       TEMPLATE_ID_EXPR.
+
 2018-03-05  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/84618
index 8125f1c..b31d4cf 100644 (file)
@@ -495,7 +495,8 @@ do_friend (tree ctype, tree declarator, tree decl,
   if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
     {
       declarator = TREE_OPERAND (declarator, 0);
-      declarator = OVL_NAME (declarator);
+      if (!identifier_p (declarator))
+       declarator = OVL_NAME (declarator);
     }
 
   if (ctype)
index 6195e21..934339d 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-05  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84694
+       * g++.dg/template/pr84694.C: New.
+
 2018-03-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/84524
diff --git a/gcc/testsuite/g++.dg/template/pr84694.C b/gcc/testsuite/g++.dg/template/pr84694.C
new file mode 100644 (file)
index 0000000..ba74560
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++84694 ICE on friend decl
+template<typename>
+struct a {
+  template<int ()> void b();
+  friend void b<0>(); // ICEd with useless friend decl
+};