diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-21 14:21:49 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-21 16:42:10 -0500 |
commit | ad09440a09597c34e0b93498aad9d6ef0b8ca9ae (patch) | |
tree | f289edc6a5ba5ab65034e39dafef9bab5f504fb8 /gcc | |
parent | 276265195a4e7362b34ac512f3bc0ad5a974dcff (diff) | |
download | gcc-ad09440a09597c34e0b93498aad9d6ef0b8ca9ae.zip gcc-ad09440a09597c34e0b93498aad9d6ef0b8ca9ae.tar.gz gcc-ad09440a09597c34e0b93498aad9d6ef0b8ca9ae.tar.bz2 |
PR c++/60855 - ICE with sizeof VLA capture.
For normal captures we usually look through them within unevaluated context,
but that doesn't work here; trying to take the sizeof of the array in the
enclosing scope tries and fails to evaluate a SAVE_EXPR from the enclosing
scope.
* lambda.c (is_lambda_ignored_entity): Don't look past VLA capture.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/lambda.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C | 12 |
3 files changed, 18 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cfc9c62..04c5d2e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2020-01-21 Jason Merrill <jason@redhat.com> + PR c++/60855 - ICE with sizeof VLA capture. + * lambda.c (is_lambda_ignored_entity): Don't look past VLA capture. + PR c++/90732 - ICE with VLA capture and generic lambda. * pt.c (tsubst_lambda_expr): Repeat add_capture for VLAs. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 50fb144..4f39f99 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1327,8 +1327,9 @@ lambda_static_thunk_p (tree fn) bool is_lambda_ignored_entity (tree val) { - /* Look past normal capture proxies. */ - if (is_normal_capture_proxy (val)) + /* Look past normal, non-VLA capture proxies. */ + if (is_normal_capture_proxy (val) + && !variably_modified_type_p (TREE_TYPE (val), NULL_TREE)) return true; /* Always ignore lambda fields, their names are only for debugging. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C new file mode 100644 index 0000000..3e9cf07 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla4.C @@ -0,0 +1,12 @@ +// PR c++/60855 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wno-vla" } + +int main() { + unsigned count = 5; + bool array[count]; + [&array] () { + array[0] = sizeof(array) > 5; + }(); + return 0; +} |