From: Paolo Carlini Date: Wed, 28 Mar 2018 19:21:41 +0000 (+0000) Subject: re PR c++/85028 (ICE on invalid C++ code: in tsubst_default_argument, at cp/pt.c... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=427d369ce186fbe89562fc16a9d2cdaec37c99c0;p=gcc.git re PR c++/85028 (ICE on invalid C++ code: in tsubst_default_argument, at cp/pt.c:12340) /cp 2018-03-28 Paolo Carlini PR c++/85028 * pt.c (tsubst_default_argument): Early return if the type of the parameter is erroneous. /testsuite 2018-03-28 Paolo Carlini PR c++/85028 * g++.dg/other/default13.C: New. From-SVN: r258932 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc7b6b9ce13..b7a4f4381e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-28 Paolo Carlini + + PR c++/85028 + * pt.c (tsubst_default_argument): Early return if the type of the + parameter is erroneous. + 2018-03-28 Alexandre Oliva PR c++/84973 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d6cce3e67da..07dad996504 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62111d459d3..d8ec226391c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-28 Paolo Carlini + + PR c++/85028 + * g++.dg/other/default13.C: New. + 2018-03-28 Jakub Jelinek 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 index 00000000000..eae23ffdf2d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default13.C @@ -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);