re PR c++/85028 (ICE on invalid C++ code: in tsubst_default_argument, at cp/pt.c...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 28 Mar 2018 19:21:41 +0000 (19:21 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 28 Mar 2018 19:21:41 +0000 (19:21 +0000)
/cp
2018-03-28  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/85028
* pt.c (tsubst_default_argument): Early return if the type of the
parameter is erroneous.

/testsuite
2018-03-28  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/85028
* g++.dg/other/default13.C: New.

From-SVN: r258932

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/default13.C [new file with mode: 0644]

index fc7b6b9..b7a4f43 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/85028
+       * pt.c (tsubst_default_argument): Early return if the type of the
+       parameter is erroneous.
+
 2018-03-28  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/84973
index d6cce3e..07dad99 100644 (file)
@@ -12337,6 +12337,9 @@ tsubst_default_argument (tree fn, int parmnum, tree type, tree arg,
   tree parmtype = TREE_TYPE (parm);
   if (DECL_BY_REFERENCE (parm))
     parmtype = TREE_TYPE (parmtype);
+  if (parmtype == error_mark_node)
+    return error_mark_node;
+
   gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, parmtype));
 
   tree *slot;
index 62111d4..d8ec226 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/85028
+       * g++.dg/other/default13.C: New.
+
 2018-03-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/85095
diff --git a/gcc/testsuite/g++.dg/other/default13.C b/gcc/testsuite/g++.dg/other/default13.C
new file mode 100644 (file)
index 0000000..eae23ff
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/85028
+
+struct A;
+
+template < typename > struct B
+{
+  B (int, A = A()) : f (0) {}  // { dg-error "incomplete type" }
+  int f;
+};
+
+B < int > b (0);