From: Jakub Jelinek Date: Tue, 21 Feb 2017 18:00:35 +0000 (+0100) Subject: re PR c++/79654 (ICE on invalid c++ code in register_dtor_fn in cp/decl.c:7877) X-Git-Tag: basepoints/gcc-8~875 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7280ac2708e2a36337347de3c27e8fda914683e;p=thirdparty%2Fgcc.git re PR c++/79654 (ICE on invalid c++ code in register_dtor_fn in cp/decl.c:7877) PR c++/79654 * decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node on error. * pt.c (tsubst_decomp_names): Return error_mark_node if the first decl after the decomposition artificial decl has error_mark_node. * decl2.c (prune_vars_needing_no_initialization): Use error_operand_p instead of just == error_mark_node comparison. * g++.dg/cpp1z/decomp26.C: New test. Co-Authored-By: Paolo Carlini From-SVN: r245639 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a63eb4be2a58..82225414bf7d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2017-02-21 Jakub Jelinek + Paolo Carlini + + PR c++/79654 + * decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node + on error. + * pt.c (tsubst_decomp_names): Return error_mark_node if the first + decl after the decomposition artificial decl has error_mark_node. + * decl2.c (prune_vars_needing_no_initialization): Use error_operand_p + instead of just == error_mark_node comparison. + 2017-02-21 Jakub Jelinek PR sanitizer/79589 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5ab9a20c829c..fa1d645e1efd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7386,7 +7386,6 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) } first = DECL_CHAIN (first); } - TREE_TYPE (decl) = error_mark_node; if (DECL_P (decl) && DECL_NAMESPACE_SCOPE_P (decl)) SET_DECL_ASSEMBLER_NAME (decl, get_identifier ("")); return; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d2e57ffe917a..b50fadf050db 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3879,7 +3879,7 @@ prune_vars_needing_no_initialization (tree *vars) tree init = TREE_PURPOSE (t); /* Deal gracefully with error. */ - if (decl == error_mark_node) + if (error_operand_p (decl)) { var = &TREE_CHAIN (t); continue; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2cac24f07145..c29e691b44c7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15610,6 +15610,11 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args, && DECL_NAME (decl2); decl2 = DECL_CHAIN (decl2)) { + if (TREE_TYPE (decl2) == error_mark_node && *cnt == 0) + { + gcc_assert (errorcount); + return error_mark_node; + } (*cnt)++; gcc_assert (DECL_HAS_VALUE_EXPR_P (decl2)); tree v = DECL_VALUE_EXPR (decl2); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abefa2db56ad..1262b2eaa797 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-02-21 Jakub Jelinek + PR c++/79654 + * g++.dg/cpp1z/decomp26.C: New test. + PR sanitizer/79589 * g++.dg/ubsan/pr79589.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp26.C b/gcc/testsuite/g++.dg/cpp1z/decomp26.C new file mode 100644 index 000000000000..f413920f5450 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp26.C @@ -0,0 +1,6 @@ +// PR c++/79654 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template T &make(); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .+1 } +auto [d1, d2] = make(); // { dg-error "cannot decompose non-array non-class type" }