diff options
| author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-08-28 00:25:06 +0000 |
|---|---|---|
| committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-08-28 00:25:06 +0000 |
| commit | 73152a2ec20766ac45673a129bf1f5fc97ca9bbe (patch) | |
| tree | cbf664452fac10a070ae23add2b0a34301bc0d24 /clang/test/SemaObjC | |
| parent | 57b4e107e43a785c38cbc16bcfd631fde80228f8 (diff) | |
| download | bcm5719-llvm-73152a2ec20766ac45673a129bf1f5fc97ca9bbe.tar.gz bcm5719-llvm-73152a2ec20766ac45673a129bf1f5fc97ca9bbe.zip | |
[ObjC] Fix type checking for qualified id block parameters.
When checking if block types are compatible, we are checking for
compatibility their return types and parameters' types. As these types
have different variance, we need to check them in different order.
rdar://problem/52788423
Reviewers: erik.pilkington, arphaman
Reviewed By: arphaman
Subscribers: jkorous, dexonsmith, ributzka, cfe-commits
Differential Revision: https://reviews.llvm.org/D66831
llvm-svn: 370130
Diffstat (limited to 'clang/test/SemaObjC')
| -rw-r--r-- | clang/test/SemaObjC/block-type-safety.m | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/block-type-safety.m b/clang/test/SemaObjC/block-type-safety.m index 96c781b6a56..66fda2d0b66 100644 --- a/clang/test/SemaObjC/block-type-safety.m +++ b/clang/test/SemaObjC/block-type-safety.m @@ -133,9 +133,20 @@ int test4 () { @end int test5() { + // Returned value is used outside of a block, so error on changing + // a return type to a more general than expected. NSAllArray *(^block)(id); id <Foo> (^genericBlock)(id); genericBlock = block; + block = genericBlock; // expected-error {{incompatible block pointer types assigning to 'NSAllArray *(^)(id)' from 'id<Foo> (^)(id)'}} + + // A parameter is used inside a block, so error on changing a parameter type + // to a more specific than an argument type it will be called with. + // rdar://problem/52788423 + void (^blockWithParam)(NSAllArray *); + void (^genericBlockWithParam)(id<Foo>); + genericBlockWithParam = blockWithParam; // expected-error {{incompatible block pointer types assigning to 'void (^)(id<Foo>)' from 'void (^)(NSAllArray *)'}} + blockWithParam = genericBlockWithParam; return 0; } |

