]> granicus.if.org Git - clang/commitdiff
Downgrade incompatible block pointer error to a warning (to be consistent with incomp...
authorSteve Naroff <snaroff@apple.com>
Wed, 24 Sep 2008 23:31:10 +0000 (23:31 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 24 Sep 2008 23:31:10 +0000 (23:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56595 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaExpr.cpp
test/Sema/block-call.c
test/Sema/block-return.c

index d266adb7c7dcacfb488585b4a06f238ee99b3a75..bbeea2a52c43cee51f2ebc68d32f60059d6dd0b5 100644 (file)
@@ -1020,7 +1020,7 @@ DIAG(err_int_to_block_pointer, ERROR,
      "invalid conversion %2 integer '%1', expected block pointer '%0'")
 DIAG(err_typecheck_comparison_of_distinct_blocks, ERROR,
      "comparison of distinct block types ('%0' and '%1')")
-DIAG(err_typecheck_convert_incompatible_block_pointer, ERROR,
+DIAG(ext_typecheck_convert_incompatible_block_pointer, EXTWARN,
      "incompatible block pointer types %2 '%1', expected '%0'")
 DIAG(ext_typecheck_convert_pointer_void_block, EXTENSION,
      "%2 '%1' converts between void* and block pointer, expected '%0'")
index e374a035cb7aa832e131b115ef16520954e255dd..1a80283f8263f8aaf3fa4d0cafead26fb8b49239 100644 (file)
@@ -3055,7 +3055,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
     DiagKind = diag::err_int_to_block_pointer;
     break;
   case IncompatibleBlockPointer:
-    DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
+    DiagKind = diag::ext_typecheck_convert_incompatible_block_pointer;
     break;
   case BlockVoidPointer:
     DiagKind = diag::ext_typecheck_convert_pointer_void_block;
index 3be4e6c43847749b3ff87440099d2362a722d0c3..871dbf792bc049e6a0d959b212d4d5aefc3788f9 100644 (file)
@@ -7,13 +7,13 @@ int main() {
   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-error {{incompatible block pointer types initializing 'int (^)()', expected 'int (^)(int)'}}
+       int (^PFR) (int) = IFP; // expected-warning {{incompatible block pointer types initializing 'int (^)()', expected 'int (^)(int)'}}
        PFR = II;       // OK
 
-       int (^IFP) () = PFR;    // expected-error {{incompatible block pointer types initializing 'int (^)(int)', expected 'int (^)()'}}
+       int (^IFP) () = PFR;    // expected-warning {{incompatible block pointer types initializing 'int (^)(int)', expected 'int (^)()'}}
 
 
-       const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
+       const int (^CIC) () = IFP; // expected-warning {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
 
 
        const int (^CICC) () = CIC;
@@ -22,9 +22,9 @@ int main() {
 
        int * const (^IPCC1) () = IPCC; 
 
-       int * (^IPCC2) () = IPCC;       // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
+       int * (^IPCC2) () = IPCC;       // expected-warning {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
 
-       int (^IPCC3) (const int) = PFR; // expected-error {{incompatible block pointer types initializing 'int (^)(int)', expected 'int (^)(int const)'}}
+       int (^IPCC3) (const int) = PFR; // expected-warning {{incompatible block pointer types initializing 'int (^)(int)', expected 'int (^)(int const)'}}
 
 
        int (^IPCC4) (int, char (^CArg) (double));
@@ -32,7 +32,7 @@ int main() {
 
        int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
 
-       int (^IPCC6) (int, char (^CArg) (float))  = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
+       int (^IPCC6) (int, char (^CArg) (float))  = IPCC4; // expected-warning {{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 *(^)()'}}
index 2110f2ce4529ede8296d1c5a9df73115a35d5ef9..6d660d140221e1ed6a874ea3ea7bbc8ae1210c14 100644 (file)
@@ -6,7 +6,7 @@ CL foo() {
 
        short y;
 
-  short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}
+  short (^add1)(void) = ^{ return y+1; }; // expected-warning {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}
 
        CL X = ^{ 
     if (2) 
@@ -27,7 +27,7 @@ CL foo() {
       return (char*)0;
   };
 
-  double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}}
+  double (^A)(void) = ^ { // expected-warning {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}}
     if (1)     
       return (float)1.0; 
     else
@@ -42,7 +42,7 @@ CL foo() {
     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}}
+  return ^{ return 1; }; // expected-warning {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}} expected-error {{returning block that lives on the local stack}}
 }
 
 typedef int (^CL2)(void);
@@ -70,3 +70,11 @@ int foo3() {
        return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
     };
 }
+
+static int funk(char *s) {
+  return 1;
+}
+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 (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}}
+}