summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-04-17 00:09:41 +0000
committerMike Stump <mrs@apple.com>2009-04-17 00:09:41 +0000
commit5c3285b6fb9a0a70ed0e839eabfff267ab03326a (patch)
tree88f36cd0a0460d8ff9145305c5f35b51a19ab047 /clang/test
parentb7f8f594f39db622ba89a570079a895c213ef651 (diff)
downloadbcm5719-llvm-5c3285b6fb9a0a70ed0e839eabfff267ab03326a.tar.gz
bcm5719-llvm-5c3285b6fb9a0a70ed0e839eabfff267ab03326a.zip
Fixup semantic analysis for nested blocks, and allow block literal
expressions that can be of static duration to be returned. Radar 6786551 llvm-svn: 69331
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Sema/block-literal.c4
-rw-r--r--clang/test/Sema/block-return.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/clang/test/Sema/block-literal.c b/clang/test/Sema/block-literal.c
index 040c383033b..2c1700a7b71 100644
--- a/clang/test/Sema/block-literal.c
+++ b/clang/test/Sema/block-literal.c
@@ -21,7 +21,7 @@ T somefunction() {
I(^{ });
- return ^{printf("\nClosure\n"); }; // expected-error {{returning block that lives on the local stack}}
+ return ^{printf("\nClosure\n"); };
}
void test2() {
int x = 4;
@@ -46,7 +46,7 @@ foo:
void (^test3())(void) {
- return ^{}; // expected-error {{returning block that lives on the local stack}}
+ return ^{};
}
void test4() {
diff --git a/clang/test/Sema/block-return.c b/clang/test/Sema/block-return.c
index d7717b38ca3..3eee002b603 100644
--- a/clang/test/Sema/block-return.c
+++ b/clang/test/Sema/block-return.c
@@ -41,13 +41,13 @@ CL foo() {
return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int', expected 'char *'}}
};
- return ^{ return 1; }; // expected-warning {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}} expected-error {{returning block that lives on the local stack}}
+ return ^{ return 1; }; // expected-warning {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}}
}
typedef int (^CL2)(void);
CL2 foo2() {
- return ^{ return 1; }; // expected-error {{returning block that lives on the local stack}}
+ return ^{ return 1; };
}
typedef unsigned int * uintptr_t;
@@ -83,3 +83,12 @@ void foo4() {
int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
+
+typedef void (^bptr)(void);
+
+bptr foo5(int j) {
+ __block int i;
+ if (j)
+ return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
+ return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
+}
OpenPOWER on IntegriCloud