Author: snaroff
Date: Wed Sep 24 18:31:10 2008
New Revision: 56595

URL: http://llvm.org/viewvc/llvm-project?rev=56595&view=rev
Log:
Downgrade incompatible block pointer error to a warning (to be consistent with 
incompatible pointer warnings in general).

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=56595&r1=56594&r2=56595&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Sep 24 18:31:10 2008
@@ -1020,7 +1020,7 @@
      "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'")

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=56595&r1=56594&r2=56595&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 24 18:31:10 2008
@@ -3055,7 +3055,7 @@
     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;

Modified: cfe/trunk/test/Sema/block-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-call.c?rev=56595&r1=56594&r2=56595&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-call.c (original)
+++ cfe/trunk/test/Sema/block-call.c Wed Sep 24 18:31:10 2008
@@ -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-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 * 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 (^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 *(^)()'}}

Modified: cfe/trunk/test/Sema/block-return.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=56595&r1=56594&r2=56595&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Wed Sep 24 18:31:10 2008
@@ -6,7 +6,7 @@
 
        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 @@
       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 @@
     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 @@
        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 *)'}}
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to