I believe that to fix this ice-on-invalid we should just make
type_dependent_expression_p more robust so that it doesn't crash on expressions
that are missing a type.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2017-02-10  Marek Polacek  <pola...@redhat.com>

        PR c++/79435
        * pt.c (type_dependent_expression_p): Check if the expression type
        is null.

        * g++.dg/cpp1y/pr79435.C: New.

diff --git gcc/cp/pt.c gcc/cp/pt.c
index 0a4510c..0bb37f8 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -23818,6 +23818,7 @@ type_dependent_expression_p (tree expression)
      we couldn't determine its length in cp_complete_array_type because
      it is dependent.  */
   if (VAR_P (expression)
+      && TREE_TYPE (expression) != NULL_TREE
       && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE
       && !TYPE_DOMAIN (TREE_TYPE (expression))
       && DECL_INITIAL (expression))
diff --git gcc/testsuite/g++.dg/cpp1y/pr79435.C 
gcc/testsuite/g++.dg/cpp1y/pr79435.C
index e69de29..a9e4671 100644
--- gcc/testsuite/g++.dg/cpp1y/pr79435.C
+++ gcc/testsuite/g++.dg/cpp1y/pr79435.C
@@ -0,0 +1,6 @@
+// PR c++/79435
+// { dg-do compile { target c++14 } }
+
+struct A;
+extern A a; // { dg-error "'a' has incomplete type" }
+template < int > int f = a.x;

        Marek

Reply via email to