PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and templates
authorMartin Sebor <msebor@redhat.com>
Thu, 15 Dec 2016 03:08:14 +0000 (03:08 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 15 Dec 2016 03:08:14 +0000 (20:08 -0700)
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
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr78774.C [new file with mode: 0644]

index 60b514b389c1dc2d2d23619df9c486f60555228e..d2e8d456023d410de03739778d1ec670e1044829 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-14  Martin Sebor  <msebor@redhat.com>
+
+       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  <mjambor@suse.cz>
 
        * parser.c: Include omp-general.h and omp-offload.h instead of
index a45e99cc59659df191533602c8fa07beedc6b57e..a21be812bafa7fe2c4abf28cd5710b252b64c323 100644 (file)
@@ -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;
index bdee8fd3e1fca3bfda50a66b6928bfca2cc6e685..88665a2c6a825c49ab86da2f679a429dd761a0c0 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-14  Martin Sebor  <msebor@redhat.com>
+
+       PR c++/78774
+       * g++.dg/cpp1y/pr78774.C: New test.
+
 2016-12-14  David Malcolm  <dmalcolm@redhat.com>
 
        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 (file)
index 0000000..c77032d
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and
+// templates
+// { dg-do compile { target c++14 } }
+
+template <int> struct ops {
+  template <int> struct A;
+  template <int *Ptr> using explode = typename A<*Ptr>::join;
+};
+template <typename Ts> typename ops<'\0'>::explode<Ts::join>::type a;