Downgrade incompatible block pointer error to a warning (to be consistent with incompatible pointer warnings in general).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56595 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index d266adb..bbeea2a 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -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'")
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index e374a03..1a80283 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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;
diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c
index 3be4e6c..871dbf7 100644
--- a/test/Sema/block-call.c
+++ b/test/Sema/block-call.c
@@ -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 *(^)()'}}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 2110f2c..6d660d1 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -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 *)'}}
+}