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 fc7b6b9ce13566653697ac25bb5bcff42a0e1800..b7a4f4381e4c418d414351708db42eed00ea6d2e 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 d6cce3e67dafd4dcec621d00443893f484764d07..07dad99650462cd774739ecfb5d143316a53f0c6 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 62111d459d3a015ce262b1fca5d03fea58a200cd..d8ec226391c38df7832b3680edad83237bcbcd7c 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);