From: Jason Merrill Date: Mon, 9 Apr 2018 15:32:05 +0000 (-0400) Subject: PR c++/85256 - ICE capturing pointer to VLA. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13c60208d0428ad14b4bd41a63a47d67bd35253f;p=gcc.git PR c++/85256 - ICE capturing pointer to VLA. * lambda.c (add_capture): Distinguish between variable-size and variably-modified types. From-SVN: r259240 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ba323bf7c20..c3751551517 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-09 Jason Merrill + + PR c++/85256 - ICE capturing pointer to VLA. + * lambda.c (add_capture): Distinguish between variable-size and + variably-modified types. + 2018-04-06 Jason Merrill PR c++/85214 - ICE with alias, generic lambda, constexpr if. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 374060626c1..e9b962a8f33 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -554,13 +554,13 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, else if (!dependent_type_p (type) && variably_modified_type_p (type, NULL_TREE)) { - error ("capture of variable-size type %qT that is not an N3639 array " + sorry ("capture of variably-modified type %qT that is not an N3639 array " "of runtime bound", type); if (TREE_CODE (type) == ARRAY_TYPE && variably_modified_type_p (TREE_TYPE (type), NULL_TREE)) inform (input_location, "because the array element type %qT has " "variable size", TREE_TYPE (type)); - type = error_mark_node; + return error_mark_node; } else { diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C index d4de131fc23..aee9694852d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C @@ -7,6 +7,6 @@ void f() { int m = 1; int d[n][m]; [&]() { - return d[1]; // { dg-error "variabl" } + return d[1]; // { dg-prune-output "sorry" } }(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla3.C new file mode 100644 index 00000000000..eebdbcdbb93 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla3.C @@ -0,0 +1,10 @@ +// PR c++/85256 +// { dg-do compile { target c++11 } } +// { dg-additional-options -Wno-vla } + +void foo(int i) +{ + int (*x)[i]; + [=]{ [=]{ 0 ? x : x; }; }; // { dg-bogus "sorry" "" { xfail *-*-* } } + +} diff --git a/gcc/testsuite/g++.dg/cpp1y/vla7.C b/gcc/testsuite/g++.dg/cpp1y/vla7.C index df34c8219db..afa5fac508d 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla7.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla7.C @@ -6,7 +6,7 @@ int main(int argc, char** argv) { int x[1][argc]; - [&x](int i) { // { dg-error "variable.size" } - x[0][i] = 0; // { dg-prune-output "assignment" } + [&x](int i) { // { dg-prune-output "sorry" } + x[0][i] = 0; // { dg-prune-output "not captured" } }(5); } diff --git a/gcc/testsuite/g++.dg/cpp1y/vla9.C b/gcc/testsuite/g++.dg/cpp1y/vla9.C index 939de30a3c1..2c5b3a5404e 100644 --- a/gcc/testsuite/g++.dg/cpp1y/vla9.C +++ b/gcc/testsuite/g++.dg/cpp1y/vla9.C @@ -25,7 +25,7 @@ int main(){ fa[0][1]=1.8; auto fx=[&](){ for(int c=0; c<2; c++){ - printf("use me", fa[0][c]); // { dg-error "capture of variable-size type" } + printf("use me", fa[0][c]); // { dg-prune-output "sorry" } } }; call(fx);