From a5dccd4614b84381f6799ae0162cd0859de0fc86 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 5 Mar 2018 16:12:07 +0000 Subject: [PATCH] [PR c++/84694] ICE on template friend decl 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 | 6 ++++++ gcc/cp/friend.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/pr84694.C | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr84694.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5e166350e40..6c37dc3eabb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-05 Nathan Sidwell + + PR c++/84694 + * friend.c (do_friend): Restore check for identifier_p inside + TEMPLATE_ID_EXPR. + 2018-03-05 Paolo Carlini PR c++/84618 diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 8125f1c34d2..b31d4cfb72c 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6195e215a9e..934339d97f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-05 Nathan Sidwell + + PR c++/84694 + * g++.dg/template/pr84694.C: New. + 2018-03-05 Jakub Jelinek 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 index 00000000000..ba74560c14d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr84694.C @@ -0,0 +1,6 @@ +// PR c++84694 ICE on friend decl +template +struct a { + template void b(); + friend void b<0>(); // ICEd with useless friend decl +}; -- 2.30.2