diff options
Diffstat (limited to 'test/SemaObjC/blocks.m')
-rw-r--r-- | test/SemaObjC/blocks.m | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m index 9926b08..b523e4c 100644 --- a/test/SemaObjC/blocks.m +++ b/test/SemaObjC/blocks.m @@ -75,10 +75,11 @@ void foo10() { // In C, enum constants have the type of the underlying integer type, not the -// enumeration they are part of. We pretend the constants have enum type when -// they are mixed with other expressions of enum type. +// enumeration they are part of. We pretend the constants have enum type if +// all the returns seem to be playing along. enum CStyleEnum { - CSE_Value = 1 + CSE_Value = 1, + CSE_Value2 = 2 }; enum CStyleEnum getCSE(); typedef enum CStyleEnum (^cse_block_t)(); @@ -92,7 +93,9 @@ void testCStyleEnumInference(bool arg) { a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} return 1; }; - a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} + + // No warning here. + a = ^{ return CSE_Value; }; @@ -114,6 +117,15 @@ void testCStyleEnumInference(bool arg) { else return 1; }; + + // rdar://13200889 + extern void check_enum(void); + a = ^{ + return (arg ? (CSE_Value) : (check_enum(), (!arg ? CSE_Value2 : getCSE()))); + }; + a = ^{ + return (arg ? (CSE_Value) : ({check_enum(); CSE_Value2; })); + }; } @@ -184,8 +196,8 @@ typedef short (^short_block_t)(); void testAnonymousEnumTypes(int arg) { int_block_t IB; IB = ^{ return AnonymousValue; }; - IB = ^{ if (arg) return TDE_Value; else return getTDE(); }; // expected-error {{incompatible block pointer}} - IB = ^{ if (arg) return getTDE(); else return TDE_Value; }; // expected-error {{incompatible block pointer}} + IB = ^{ if (arg) return TDE_Value; else return getTDE(); }; + IB = ^{ if (arg) return getTDE(); else return TDE_Value; }; // Since we fixed the underlying type of the enum, these are considered // compatible block types anyway. |