aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-05-28 14:00:29 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-05-28 14:00:29 +0000
commitde1644122d0ad0a727042089083595cdfa99815f (patch)
tree967d3d3302cdf836d0b473a98e889899c67b7f38
parent997636716c5dde7d59d026726a6f58918069f122 (diff)
downloadgcc-de1644122d0ad0a727042089083595cdfa99815f.zip
gcc-de1644122d0ad0a727042089083595cdfa99815f.tar.gz
gcc-de1644122d0ad0a727042089083595cdfa99815f.tar.bz2
PR c++/90548 - ICE with generic lambda and empty pack.
* pt.c (tsubst_copy_and_build): Handle pack expansion properly. * g++.dg/cpp1y/lambda-generic-90548.C: New test. From-SVN: r271705
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c23
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-90548.C22
4 files changed, 48 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 001c53e..36a415d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-28 Marek Polacek <polacek@redhat.com>
+
+ PR c++/90548 - ICE with generic lambda and empty pack.
+ * pt.c (tsubst_copy_and_build): Handle pack expansion properly.
+
2019-05-28 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (make_anon_name): Drop declaration.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e52668a..cfbd9fd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18861,6 +18861,9 @@ tsubst_copy_and_build (tree t,
the thunk template for a generic lambda. */
if (CALL_FROM_THUNK_P (t))
{
+ /* Now that we've expanded any packs, the number of call args
+ might be different. */
+ unsigned int cargs = call_args->length ();
tree thisarg = NULL_TREE;
if (TREE_CODE (function) == COMPONENT_REF)
{
@@ -18874,7 +18877,7 @@ tsubst_copy_and_build (tree t,
/* We aren't going to do normal overload resolution, so force the
template-id to resolve. */
function = resolve_nondeduced_context (function, complain);
- for (unsigned i = 0; i < nargs; ++i)
+ for (unsigned i = 0; i < cargs; ++i)
{
/* In a thunk, pass through args directly, without any
conversions. */
@@ -18885,12 +18888,18 @@ tsubst_copy_and_build (tree t,
}
if (thisarg)
{
- /* Shift the other args over to make room. */
- tree last = (*call_args)[nargs - 1];
- vec_safe_push (call_args, last);
- for (int i = nargs-1; i > 0; --i)
- (*call_args)[i] = (*call_args)[i-1];
- (*call_args)[0] = thisarg;
+ /* If there are no other args, just push 'this'. */
+ if (cargs == 0)
+ vec_safe_push (call_args, thisarg);
+ else
+ {
+ /* Otherwise, shift the other args over to make room. */
+ tree last = (*call_args)[cargs - 1];
+ vec_safe_push (call_args, last);
+ for (int i = cargs - 1; i > 0; --i)
+ (*call_args)[i] = (*call_args)[i - 1];
+ (*call_args)[0] = thisarg;
+ }
}
ret = build_call_a (function, call_args->length (),
call_args->address ());
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f4be27..663cedb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-28 Marek Polacek <polacek@redhat.com>
+
+ PR c++/90548 - ICE with generic lambda and empty pack.
+ * g++.dg/cpp1y/lambda-generic-90548.C: New test.
+
2019-05-28 Alejandro Martinez <alejandro.martinezvicente@arm.com>
* gcc.target/aarch64/sve/mask_load_slp_1.c: New test for SLP
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90548.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90548.C
new file mode 100644
index 0000000..b845dd8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90548.C
@@ -0,0 +1,22 @@
+// PR c++/90548
+// { dg-do compile { target c++14 } }
+
+struct S { S (void ()); };
+S foo([] (auto...) { });
+S foo2{[] (auto...) {}};
+S foo3 = {[] (auto...) {}};
+
+struct W { W(void (int)); };
+W bar([](auto...) { });
+W bar2{[](auto...) { }};
+W bar3 = {[](auto...) { }};
+
+struct T { T(void (int, int)); };
+T qux([](auto...) { });
+T qux2{[](auto...) { }};
+T qux3 = {[](auto...) { }};
+
+struct R { R(void (int, int, int, int, int, int, int, int, int, int)); };
+R baz([](auto...) { });
+R baz2{[](auto...) { }};
+R baz3 = {[](auto...) { }};