[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 5e166350e40a8273f47cfbe6104a7ecddc92fb80..6c37dc3eabb0b0a8438a695de6f83cb551a612ff 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 8125f1c34d2741ab2beb44c88e2a158fe4ebbd0c..b31d4cfb72c466d637dc49476edd84bc1d31aa88 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 6195e215a9e2e33268cf2c8f5ff250683ec23ffc..934339d97f705aacb5b965dcf9166053e2fe0fc4 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
+};