diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-28 23:09:44 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-28 23:09:44 +0000 |
| commit | 8cb63232d9c7c18a27e36edcd16ae42b2eccefee (patch) | |
| tree | 95b8021376c56b45ab9a09111c2da0c033b0d31e /clang/test | |
| parent | 94ef686f575c5cd66b0b30e34aaa5dc7b05ad361 (diff) | |
| download | bcm5719-llvm-8cb63232d9c7c18a27e36edcd16ae42b2eccefee.tar.gz bcm5719-llvm-8cb63232d9c7c18a27e36edcd16ae42b2eccefee.zip | |
If capturing a variable fails, add a capture anyway (and mark it
invalid) so that we can avoid repeated diagnostics for the same capture.
llvm-svn: 361891
Diffstat (limited to 'clang/test')
4 files changed, 20 insertions, 5 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm index 96e8fcd8d37..cb56f6816ad 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm @@ -50,6 +50,13 @@ void nesting() { [=] () mutable { ^ { int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}} + i += array[3]; + }(); + }(); + + [=] () mutable { + ^ { + int i = 0; i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}} }(); }(); diff --git a/clang/test/Sema/captured-statements.c b/clang/test/Sema/captured-statements.c index 86e9273944b..ac04915097e 100644 --- a/clang/test/Sema/captured-statements.c +++ b/clang/test/Sema/captured-statements.c @@ -65,11 +65,18 @@ void test_nest_block() { int b; #pragma clang __debug captured { - __block int c; int d; ^{ a = b; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} + a = b; // (duplicate diagnostic suppressed) b = d; // OK - Consistent with block inside a lambda + }(); + } + #pragma clang __debug captured + { + __block int c; + int d; + ^{ c = a; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} c = d; // OK d = b; // expected-error{{variable is not assignable (missing __block type specifier)}} diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index 1833400be3d..8b0b83078b0 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -65,9 +65,9 @@ namespace ImplicitCapture { d = 3; [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} - __block int e; // expected-note 3 {{declared}} + __block int e; // expected-note 2{{declared}} [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} - [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} + [&e]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} int f[10]; // expected-note {{declared}} [&]() { return f[2]; }; diff --git a/clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm b/clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm index d7d888564c1..cf88d4684c5 100644 --- a/clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm +++ b/clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm @@ -2,7 +2,8 @@ // rdar://12655829 void f() { - struct { int x; int y[]; } a; // expected-note 2 {{'a' declared here}} + struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}} ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}} - [] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}} + [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}} + [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} } |

