summaryrefslogtreecommitdiffstats
path: root/test/Sema/block-return.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/block-return.c')
-rw-r--r--test/Sema/block-return.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 5a4ec01..c6e1e9d 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -78,10 +78,10 @@ static int funk(char *s) {
}
void next();
void foo4() {
- int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char const *)' with an expression of type 'int (^)(char *)'}}
- int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(char const *)' with an expression of type 'int (char *)'}}
+ int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
+ int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
- 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 *, ...)'}} \
+ 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 (const char *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
@@ -97,7 +97,8 @@ bptr foo5(int j) {
}
int (*funcptr3[5])(long);
-int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block declared as returning an array}}
+int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
+int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}}
void foo6() {
int (^b)(int) __attribute__((noreturn));
@@ -109,7 +110,7 @@ void foo6() {
void foo7()
{
- const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}}
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // OK - initializing 'const int (^)(void)' with an expression of type 'int (^)(void)'
const int (^CC) (void) = ^const int{ const int i = 1; return i; };
OpenPOWER on IntegriCloud