diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-27 02:35:39 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-27 02:35:39 +0000 |
commit | cc13ebcbc5c2195a4cd76beae94c50455eaa1c97 (patch) | |
tree | d1e89f09f1308526bc2f220bb5bba97fb6b40a74 | |
parent | 01f6669b242d66fc9fd768a8ec8281c7dd576cef (diff) | |
download | gcc-cc13ebcbc5c2195a4cd76beae94c50455eaa1c97.tar.gz |
PR c++/57408
* semantics.c (add_capture): Set type to error_mark_node after
error.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200449 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/vla9.C | 31 |
3 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bd82693722c..3be2f1e715d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-06-21 Jason Merrill <jason@redhat.com> + + PR c++/57408 + * semantics.c (add_capture): Set type to error_mark_node after + error. + 2013-06-25 Ed Smith-Rowland <3dw4rd@verizon.net> PR c++/57640 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0a460a42544..4c76b80d0cd 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9521,6 +9521,7 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, && 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; } else if (by_reference_p) { diff --git a/gcc/testsuite/g++.dg/cpp1y/vla9.C b/gcc/testsuite/g++.dg/cpp1y/vla9.C new file mode 100644 index 00000000000..ea5c4d8eedb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/vla9.C @@ -0,0 +1,31 @@ +// PR c++/57408 +// { dg-options "-std=c++1y -pedantic-errors" } + +template<typename Callable> + struct Impl + { + Callable func; + Impl(Callable f) : func(f) { } + virtual void run() { func(); } + }; + +template<typename Callable> +void call(Callable f) + { + Impl<Callable>(f).run(); + } + +extern "C" int printf(const char*, ...); + +int main(){ + int y = 2; + float fa[2][y]; // { dg-error "array of array of runtime bound" } + fa[0][0]=0.8; + 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" } + } + }; + call(fx); +} |