aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-30 17:21:25 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-30 17:21:25 -0400
commitf026530a85c3d13aaebec5c4e96cd0a2f6ef4f17 (patch)
tree0b723e6548ef3884af4b49ddcad43de0c2aad2c2
parentd6df811e5db4d0f2cfa27c33dd97bf0ab3fe0822 (diff)
downloadgcc-f026530a85c3d13aaebec5c4e96cd0a2f6ef4f17.zip
gcc-f026530a85c3d13aaebec5c4e96cd0a2f6ef4f17.tar.gz
gcc-f026530a85c3d13aaebec5c4e96cd0a2f6ef4f17.tar.bz2
PR c++/85305 - pack in lambda init-capture.
* parser.c (cp_parser_initializer): Add subexpression_p parm; don't check_for_bare_parameter_packs in a subexpression. (cp_parser_lambda_introducer): Use it. From-SVN: r259779
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c8
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C8
3 files changed, 17 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1ab9158..95f77f4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2018-04-30 Jason Merrill <jason@redhat.com>
+ PR c++/85305 - pack in lambda init-capture.
+ * parser.c (cp_parser_initializer): Add subexpression_p parm; don't
+ check_for_bare_parameter_packs in a subexpression.
+ (cp_parser_lambda_introducer): Use it.
+
PR c++/61982 - dead stores to destroyed objects.
* call.c (build_trivial_dtor_call): New, assigns a clobber.
(build_over_call, build_special_member_call): Use it.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d8ce28a..b839232 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2243,7 +2243,7 @@ static tree cp_parser_default_argument
static void cp_parser_function_body
(cp_parser *, bool);
static tree cp_parser_initializer
- (cp_parser *, bool *, bool *);
+ (cp_parser *, bool *, bool *, bool = false);
static cp_expr cp_parser_initializer_clause
(cp_parser *, bool *);
static cp_expr cp_parser_braced_list
@@ -10358,7 +10358,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
"lambda capture initializers "
"only available with -std=c++14 or -std=gnu++14");
capture_init_expr = cp_parser_initializer (parser, &direct,
- &non_constant);
+ &non_constant, true);
explicit_init_p = true;
if (capture_init_expr == NULL_TREE)
{
@@ -21860,7 +21860,7 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser,
static tree
cp_parser_initializer (cp_parser* parser, bool* is_direct_init,
- bool* non_constant_p)
+ bool* non_constant_p, bool subexpression_p)
{
cp_token *token;
tree init;
@@ -21907,7 +21907,7 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init,
init = error_mark_node;
}
- if (check_for_bare_parameter_packs (init))
+ if (!subexpression_p && check_for_bare_parameter_packs (init))
init = error_mark_node;
return init;
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C b/gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C
new file mode 100644
index 0000000..e93f55f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C
@@ -0,0 +1,8 @@
+// PR c++/85305
+// { dg-additional-options -std=c++17 }
+
+template <int... Is>
+void foo()
+{
+ ([i = Is]{}(), ...);
+}