diff options
author | Steve Naroff <snaroff@apple.com> | 2008-09-16 22:25:10 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-09-16 22:25:10 +0000 |
commit | c50a4a5f2eac14ac4c631d50b0a55cadc87700ce (patch) | |
tree | 694ec8327f92d8727d2c3db3bcd4f77a1db29e85 /test/Sema/block-return.c | |
parent | d452758bb6b59340528a26def9ecc24b329d4ecf (diff) | |
download | clang-c50a4a5f2eac14ac4c631d50b0a55cadc87700ce.tar.gz |
Sema::ActOnBlockReturnStmt(): Need to perform the UsualUnaryConversions on the return type.
Sema::CheckReturnStackAddr(): Make sure we skip over implicit casts.
Added some more test cases...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/block-return.c')
-rw-r--r-- | test/Sema/block-return.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c new file mode 100644 index 0000000000..93511dbd7e --- /dev/null +++ b/test/Sema/block-return.c @@ -0,0 +1,52 @@ +// RUN: clang -fsyntax-only %s -verify + +typedef void (^CL)(void); + +CL foo() { + + short y; + + short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}} + + CL X = ^{ + if (2) + return; + return 1; // expected-error {{void block should not return a value}} + }; + int (^Y) (void) = ^{ + if (3) + return 1; + else + return; // expected-error {{non-void block should return a value}} + }; + + char *(^Z)(void) = ^{ + if (3) + return ""; + else + return (char*)0; + }; + + double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}} + if (1) + return (float)1.0; + else + if (2) + return (double)2.0; // expected-error {{incompatible type returning 'double', expected 'float'}} + return 1; // expected-error {{incompatible type returning 'int', expected 'float'}} + }; + + char *(^B)(void) = ^{ + if (3) + return ""; + else + return 2; // expected-error {{incompatible type returning 'int', expected 'char *'}} + }; + return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}} expected-error {{returning block that lives on the local stack}} +} + +typedef int (^CL2)(void); + +CL2 foo2() { + return ^{ return 1; }; // expected-error {{returning block that lives on the local stack}} +} |