aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/block-return.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-03 00:27:59 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-03 00:27:59 +0000
commita873dfc9e7314681bb37efd9ab185045de121e43 (patch)
treedaf26e6ef55f2408e3a8f421914ae76e5e089873 /test/Sema/block-return.c
parent2f764f11f513c7b51c716fffa5d02e5de816836f (diff)
Implement the lvalue-to-rvalue conversion where needed. The
lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/block-return.c')
-rw-r--r--test/Sema/block-return.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 6416545cb7..2385106630 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -109,7 +109,7 @@ void foo6() {
void foo7()
{
- const int (^BB) (void) = ^{ const int i = 1; return i; }; // OK
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int (^)(void)', expected 'int const (^)(void)'}}
const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // OK
int i;
@@ -123,9 +123,8 @@ void foo7()
__block const int k;
const int cint = 100;
- int (^MM) (void) = ^{ return k; }; // expected-error {{incompatible block pointer types initializing 'int const (^)(void)', expected 'int (^)(void)'}}
- int (^NN) (void) = ^{ return cint; }; // expected-error {{incompatible block pointer types initializing 'int const (^)(void)', expected 'int (^)(void)'}}
-
+ int (^MM) (void) = ^{ return k; };
+ int (^NN) (void) = ^{ return cint; };
}