| 1 |
// RUN: %clang_cc1 -S -o - -triple i686-windows -verify -fblocks \ |
| 2 |
// RUN: -Wno-unused-comparison %s |
| 3 |
|
| 4 |
#pragma clang diagnostic ignored "-Wunused-comparison" |
| 5 |
|
| 6 |
#define nil ((id)nullptr) |
| 7 |
|
| 8 |
@protocol NSObject |
| 9 |
@end |
| 10 |
|
| 11 |
@protocol NSCopying |
| 12 |
@end |
| 13 |
|
| 14 |
@protocol OtherProtocol |
| 15 |
@end |
| 16 |
|
| 17 |
__attribute__((objc_root_class)) |
| 18 |
@interface NSObject <NSObject, NSCopying> |
| 19 |
@end |
| 20 |
|
| 21 |
__attribute__((objc_root_class)) |
| 22 |
@interface Test |
| 23 |
@end |
| 24 |
|
| 25 |
int main() { |
| 26 |
void (^block)() = ^{}; |
| 27 |
NSObject *object; |
| 28 |
id<NSObject, NSCopying> qualifiedId; |
| 29 |
|
| 30 |
id<OtherProtocol> poorlyQualified1; |
| 31 |
Test *objectOfWrongType; |
| 32 |
|
| 33 |
block == nil; |
| 34 |
block == object; |
| 35 |
block == qualifiedId; |
| 36 |
|
| 37 |
nil == block; |
| 38 |
object == block; |
| 39 |
qualifiedId == block; |
| 40 |
|
| 41 |
// these are still not valid: blocks must be compared with id, NSObject*, or a protocol-qualified id |
| 42 |
// conforming to NSCopying or NSObject. |
| 43 |
|
| 44 |
block == poorlyQualified1; // expected-error {{invalid operands to binary expression ('void (^)()' and 'id<OtherProtocol>')}} |
| 45 |
block == objectOfWrongType; // expected-error {{invalid operands to binary expression ('void (^)()' and 'Test *')}} |
| 46 |
|
| 47 |
poorlyQualified1 == block; // expected-error {{invalid operands to binary expression ('id<OtherProtocol>' and 'void (^)()')}} |
| 48 |
objectOfWrongType == block; // expected-error {{invalid operands to binary expression ('Test *' and 'void (^)()')}} |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |