Tighten up blocks type checking.  This was discussed back in the
r56595 timeframe, but left undone.  Radar 6812711


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69745 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 20fa1e8..7c49cfb 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index fa85757..81bac66 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c
index 34de8b6..9d3ff71 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-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 *(^)()'}}
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index bef2662..dbcc253 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -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}}
+}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 3eee002..e6101d1 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -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 *, ...)'}} \
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 544eddd..baadbde 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -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)) {