[cfe-commits] r69745 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/block-call.c test/Sema/block-misc.c test/Sema/block-return.c test/SemaObjC/blocks.m
Mike Stump
mrs at apple.com
Tue Apr 21 15:51:43 PDT 2009
Author: mrs
Date: Tue Apr 21 17:51:42 2009
New Revision: 69745
URL: http://llvm.org/viewvc/llvm-project?rev=69745&view=rev
Log:
Tighten up blocks type checking. This was discussed back in the
r56595 timeframe, but left undone. Radar 6812711
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/block-call.c
cfe/trunk/test/Sema/block-misc.c
cfe/trunk/test/Sema/block-return.c
cfe/trunk/test/SemaObjC/blocks.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 21 17:51:42 2009
@@ -1242,7 +1242,7 @@
"invalid conversion %2 integer %1, expected block pointer %0">;
def err_typecheck_comparison_of_distinct_blocks : Error<
"comparison of distinct block types (%0 and %1)">;
-def ext_typecheck_convert_incompatible_block_pointer : ExtWarn<
+def err_typecheck_convert_incompatible_block_pointer : Error<
"incompatible block pointer types %2 %1, expected %0">;
def err_typecheck_array_not_modifiable_lvalue : Error<
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Apr 21 17:51:42 2009
@@ -4894,7 +4894,7 @@
DiagKind = diag::err_int_to_block_pointer;
break;
case IncompatibleBlockPointer:
- DiagKind = diag::ext_typecheck_convert_incompatible_block_pointer;
+ DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
break;
case IncompatibleObjCQualifiedId:
// FIXME: Diagnose the problem in ObjCQualifiedIdTypesAreCompatible, since
Modified: cfe/trunk/test/Sema/block-call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-call.c?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-call.c (original)
+++ cfe/trunk/test/Sema/block-call.c Tue Apr 21 17:51:42 2009
@@ -7,13 +7,13 @@
int (*FPL) (int) = FP; // C doesn't consider this an error.
// For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error.
- int (^PFR) (int) = IFP; // expected-warning {{incompatible block pointer types initializing 'int (^)()', expected 'int (^)(int)'}}
+ int (^PFR) (int) = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int (^)(int)'}}
PFR = II; // OK
int (^IFP) () = PFR;
- const int (^CIC) () = IFP; // expected-warning {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
+ const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
const int (^CICC) () = CIC;
@@ -22,7 +22,7 @@
int * const (^IPCC1) () = IPCC;
- int * (^IPCC2) () = IPCC; // expected-warning {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
+ int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
int (^IPCC3) (const int) = PFR;
@@ -32,7 +32,7 @@
int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
- int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-warning {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
+ int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
IPCC2 = 0;
IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}}
Modified: cfe/trunk/test/Sema/block-misc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-misc.c (original)
+++ cfe/trunk/test/Sema/block-misc.c Tue Apr 21 17:51:42 2009
@@ -112,13 +112,16 @@
^{ break; }(); // expected-error {{'break' statement not in loop or switch statement}}
}
+enum { LESS };
+
+void foo(long (^comp)()) {
+}
void (^test12f)(void);
void test12() {
- test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
+ foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}}
}
-
// rdar://6808730
void *test13 = ^{
int X = 32;
@@ -138,3 +141,8 @@
};
};
}
+
+void (^test90f)(void);
+void test90() {
+ test90f = ^test90f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
+}
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Tue Apr 21 17:51:42 2009
@@ -4,7 +4,7 @@
CL foo() {
short y;
- short (^add1)(void) = ^{ return y+1; }; // expected-warning {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}
+ short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}
CL X = ^{
if (2)
@@ -26,7 +26,7 @@
return (char*)0;
};
- double (^A)(void) = ^ { // expected-warning {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}}
+ double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}}
if (1)
return (float)1.0;
else
@@ -41,7 +41,7 @@
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'}}
+ return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}}
}
typedef int (^CL2)(void);
@@ -77,7 +77,7 @@
return 0;
}
void foo4() {
- int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-warning {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}}
+ int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected '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 (char const *, ...)'}} \
Modified: cfe/trunk/test/SemaObjC/blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/blocks.m?rev=69745&r1=69744&r2=69745&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/blocks.m (original)
+++ cfe/trunk/test/SemaObjC/blocks.m Tue Apr 21 17:51:42 2009
@@ -23,12 +23,12 @@
void bar5(id(^)(void));
void foo5(id (^objectCreationBlock)(int)) {
- return bar5(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}}
+ return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)', expected 'id (^)(void)'}}
}
void bar6(id(^)(int));
void foo6(id (^objectCreationBlock)()) {
- return bar6(objectCreationBlock); // expected-warning{{incompatible block pointer types passing 'id (^)()', expected 'id (^)(int)'}}
+ return bar6(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)()', expected 'id (^)(int)'}}
}
void foo7(id (^x)(int)) {
More information about the cfe-commits
mailing list