diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGenCXX/blocks.cpp | 25 | ||||
-rw-r--r-- | test/SemaCXX/blocks.cpp | 20 |
2 files changed, 44 insertions, 1 deletions
diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp index 209213999e..914c0695cc 100644 --- a/test/CodeGenCXX/blocks.cpp +++ b/test/CodeGenCXX/blocks.cpp @@ -228,3 +228,28 @@ namespace test8 { template int X::foo<int>(); } + +// rdar://13459289 +namespace test9 { + struct B { + void *p; + B(); + B(const B&); + ~B(); + }; + + void use_block(void (^)()); + void use_block_2(void (^)(), const B &a); + + // Ensuring that creating a non-trivial capture copy expression + // doesn't end up stealing the block registration for the block we + // just parsed. That block must have captures or else it won't + // force registration. Must occur within a block for some reason. + void test() { + B x; + use_block(^{ + int y; + use_block_2(^{ (void)y; }, x); + }); + } +} diff --git a/test/SemaCXX/blocks.cpp b/test/SemaCXX/blocks.cpp index a635e998d9..a2672d13b7 100644 --- a/test/SemaCXX/blocks.cpp +++ b/test/SemaCXX/blocks.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fblocks -// expected-no-diagnostics void tovoid(void*); @@ -82,3 +81,22 @@ void move_block() { __block MoveOnly mo; } +// Don't crash after failing to build a block due to a capture of an +// invalid declaration. +namespace test5 { + struct B { // expected-note 2 {{candidate constructor}} + void *p; + B(int); // expected-note {{candidate constructor}} + }; + + void use_block(void (^)()); + void use_block_2(void (^)(), const B &a); + + void test() { + B x; // expected-error {{no matching constructor for initialization}} + use_block(^{ + int y; + use_block_2(^{ (void) y; }, x); + }); + } +} |