aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-02-10 22:51:30 -0500
committerMarek Polacek <polacek@redhat.com>2021-02-11 11:12:49 -0500
commitf0da1c0cb7661ee9111bc475efddae80a026de34 (patch)
tree7920ddc5775bb5acdb6ec0552845ca8032c3d56a /gcc/cp/semantics.c
parentcb168f779c87c1e0c37d22ea82dfb93ff8c873bc (diff)
downloadgcc-f0da1c0cb7661ee9111bc475efddae80a026de34.zip
gcc-f0da1c0cb7661ee9111bc475efddae80a026de34.tar.gz
gcc-f0da1c0cb7661ee9111bc475efddae80a026de34.tar.bz2
c++: ICE with unexpanded pack in do-while [PR99063]
Here an unexpanded parameter pack snuck into prep_operand which doesn't expect to see an operand without a type, and since r247842 NONTYPE_ARGUMENT_PACK doesn't have a type anymore. This only happens with the do-while loop whose condition may not contain a declaration so we never called finish_cond which checks for unexpanded parameter packs. So use check_for_bare_parameter_packs to remedy that. gcc/cp/ChangeLog: PR c++/99063 * semantics.c (finish_do_stmt): Check for unexpanded parameter packs. gcc/testsuite/ChangeLog: PR c++/99063 * g++.dg/cpp0x/variadic-crash6.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7383446..30dd206 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1028,6 +1028,11 @@ finish_do_stmt (tree cond, tree do_stmt, bool ivdep, unsigned short unroll)
{
cond = maybe_convert_cond (cond);
end_maybe_infinite_loop (cond);
+ /* Unlike other iteration statements, the condition may not contain
+ a declaration, so we don't call finish_cond which checks for
+ unexpanded parameter packs. */
+ if (check_for_bare_parameter_packs (cond))
+ cond = error_mark_node;
if (ivdep && cond != error_mark_node)
cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
build_int_cst (integer_type_node, annot_expr_ivdep_kind),