From 1750f2a55a7f17c557fa591691a15c363181fa80 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 15 Dec 2016 03:08:14 +0000 Subject: [PATCH] PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and templates gcc/cp/ChangeLog: PR c++/78774 * pt.c (convert_template_argument): Avoid assuming operand type is non-null since that of SCOPE_REF is not. gcc/testsuite/ChangeLog: PR c++/78774 * g++.dg/cpp1y/pr78774.C: New test. From-SVN: r243683 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/pr78774.C | 9 +++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr78774.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 60b514b..d2e8d45 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-12-14 Martin Sebor + + PR c++/78774 + * pt.c (convert_template_argument): Avoid assuming operand type + is non-null since that of SCOPE_REF is not. + 2016-12-14 Martin Jambor * parser.c: Include omp-general.h and omp-offload.h instead of diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a45e99c..a21be81 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7379,9 +7379,10 @@ convert_template_argument (tree parm, /* Reject template arguments that are references to built-in functions with no library fallbacks. */ const_tree inner = TREE_OPERAND (val, 0); - if (TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE - && TREE_CODE (TREE_TYPE (TREE_TYPE (inner))) == FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE + const_tree innertype = TREE_TYPE (inner); + if (innertype + && TREE_CODE (innertype) == REFERENCE_TYPE + && TREE_CODE (TREE_TYPE (innertype)) == FUNCTION_TYPE && 0 < TREE_OPERAND_LENGTH (inner) && reject_gcc_builtin (TREE_OPERAND (inner, 0))) return error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bdee8fd..88665a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-14 Martin Sebor + + PR c++/78774 + * g++.dg/cpp1y/pr78774.C: New test. + 2016-12-14 David Malcolm PR target/78213 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr78774.C b/gcc/testsuite/g++.dg/cpp1y/pr78774.C new file mode 100644 index 0000000..c77032d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr78774.C @@ -0,0 +1,9 @@ +// PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and +// templates +// { dg-do compile { target c++14 } } + +template struct ops { + template struct A; + template using explode = typename A<*Ptr>::join; +}; +template typename ops<'\0'>::explode::type a; -- 2.7.4