Commit 13c60208 by Jason Merrill Committed by Jason Merrill

PR c++/85256 - ICE capturing pointer to VLA.

	* lambda.c (add_capture): Distinguish between variable-size and
	variably-modified types.

From-SVN: r259240
parent cca538a4
2018-04-09 Jason Merrill <jason@redhat.com>
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 <jason@redhat.com> 2018-04-06 Jason Merrill <jason@redhat.com>
PR c++/85214 - ICE with alias, generic lambda, constexpr if. PR c++/85214 - ICE with alias, generic lambda, constexpr if.
......
...@@ -554,13 +554,13 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, ...@@ -554,13 +554,13 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
else if (!dependent_type_p (type) else if (!dependent_type_p (type)
&& variably_modified_type_p (type, NULL_TREE)) && 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); "of runtime bound", type);
if (TREE_CODE (type) == ARRAY_TYPE if (TREE_CODE (type) == ARRAY_TYPE
&& variably_modified_type_p (TREE_TYPE (type), NULL_TREE)) && variably_modified_type_p (TREE_TYPE (type), NULL_TREE))
inform (input_location, "because the array element type %qT has " inform (input_location, "because the array element type %qT has "
"variable size", TREE_TYPE (type)); "variable size", TREE_TYPE (type));
type = error_mark_node; return error_mark_node;
} }
else else
{ {
......
...@@ -7,6 +7,6 @@ void f() { ...@@ -7,6 +7,6 @@ void f() {
int m = 1; int m = 1;
int d[n][m]; int d[n][m];
[&]() { [&]() {
return d[1]; // { dg-error "variabl" } return d[1]; // { dg-prune-output "sorry" }
}(); }();
} }
// 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 *-*-* } }
}
...@@ -6,7 +6,7 @@ int main(int argc, char** argv) ...@@ -6,7 +6,7 @@ int main(int argc, char** argv)
{ {
int x[1][argc]; int x[1][argc];
[&x](int i) { // { dg-error "variable.size" } [&x](int i) { // { dg-prune-output "sorry" }
x[0][i] = 0; // { dg-prune-output "assignment" } x[0][i] = 0; // { dg-prune-output "not captured" }
}(5); }(5);
} }
...@@ -25,7 +25,7 @@ int main(){ ...@@ -25,7 +25,7 @@ int main(){
fa[0][1]=1.8; fa[0][1]=1.8;
auto fx=[&](){ auto fx=[&](){
for(int c=0; c<2; c++){ 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); call(fx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment