aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-02-21 09:56:31 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-02-21 09:56:31 -0500
commit1c195d2a8fcc6161198e2be68293cd824051b063 (patch)
treed699b4b6ed6349c862784364a90e6f787d63ad9c /gcc
parente9cd655135c621b4df78551676eefe6ebd3e6390 (diff)
downloadgcc-1c195d2a8fcc6161198e2be68293cd824051b063.zip
gcc-1c195d2a8fcc6161198e2be68293cd824051b063.tar.gz
gcc-1c195d2a8fcc6161198e2be68293cd824051b063.tar.bz2
re PR c++/60252 ([c++11] ICE with invalid variable-length array in lambda parameter)
PR c++/60252 * lambda.c (maybe_resolve_dummy): Don't try to capture this in declaration context. From-SVN: r207999
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/lambda.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C12
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8a2cb16..28ce725 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2014-02-21 Jason Merrill <jason@redhat.com>
+ PR c++/60252
+ * lambda.c (maybe_resolve_dummy): Don't try to capture this
+ in declaration context.
+
DR 1591
PR c++/60051
* pt.c (unify): Only unify if deducible. Handle 0-length list.
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index ad993e9d..7fe235b 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -749,7 +749,10 @@ maybe_resolve_dummy (tree object)
if (type != current_class_type
&& current_class_type
&& LAMBDA_TYPE_P (current_class_type)
- && DERIVED_FROM_P (type, current_nonlambda_class_type ()))
+ && DERIVED_FROM_P (type, current_nonlambda_class_type ())
+ /* If we get here while parsing the parameter list of a lambda, it
+ will fail, so don't even try (c++/60252). */
+ && current_binding_level->kind != sk_function_parms)
{
/* In a lambda, need to go through 'this' capture. */
tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C
new file mode 100644
index 0000000..58f0fa3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C
@@ -0,0 +1,12 @@
+// PR c++/60252
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ int i; // { dg-message "" }
+
+ void foo()
+ {
+ [&](){ [&](int[i]){}; }; // { dg-error "" }
+ }
+};