diff options
| author | John McCall <rjmccall@apple.com> | 2013-03-09 00:54:31 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2013-03-09 00:54:31 +0000 |
| commit | e4c11cc7e5309aa8c75052edabd2f6095bc0ab40 (patch) | |
| tree | 9d214e51703ca4b75bbf726879688bafb43ca122 /clang/test | |
| parent | 5ea957701641c5d6f4186957a1fed0968a67fc4f (diff) | |
| download | bcm5719-llvm-e4c11cc7e5309aa8c75052edabd2f6095bc0ab40.tar.gz bcm5719-llvm-e4c11cc7e5309aa8c75052edabd2f6095bc0ab40.zip | |
Adjust the special non-C++ enum block return type inference
so that it looks through certain syntactic forms and applies
even if normal inference would have succeeded.
There is potential for source incompatibility from this
change, but overall we feel that it produces a much
cleaner and more defensible result, and the block
compatibility rules should curb a lot of the potential
for annoyance.
rdar://13200889
llvm-svn: 176743
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaObjC/blocks.m | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/test/SemaObjC/blocks.m b/clang/test/SemaObjC/blocks.m index 9926b0835f5..dd659addefd 100644 --- a/clang/test/SemaObjC/blocks.m +++ b/clang/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; })); + }; } |

