More type checking for blocks. Still incomplete (will hopefully finish up this weekend).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55862 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
new file mode 100644
index 0000000..92632f3
--- /dev/null
+++ b/test/Sema/block-misc.c
@@ -0,0 +1,50 @@
+// RUN: clang -fsyntax-only -verify %s
+void donotwarn();
+
+int (^IFP) ();
+int (^II) (int);
+int test1() {
+	int (^PFR) (int) = 0;	// OK
+	PFR = II;	// OK
+
+	if (PFR == II)	// OK
+	  donotwarn();
+
+	if (PFR == IFP) // expected-error {{comparison of distinct block types}}
+	  donotwarn();
+
+	if (PFR == (int (^) (int))IFP) // OK
+	  donotwarn();
+
+	if (PFR == 0) // OK
+	  donotwarn();
+
+	if (PFR)	// OK
+	  donotwarn();
+
+	if (!PFR)	// OK
+	  donotwarn();
+
+	return PFR != IFP;	// expected-error {{comparison of distinct block types}}
+}
+
+int test2(double (^S)()) {
+   double (^I)(int)  = (void*) S;
+   (void*)I = (void *)S; 	// expected-error {{expression is not assignable}}
+
+   void *pv = I;
+
+   pv = S;		
+
+   I(1);
+ 
+   return (void*)I == (void *)S;
+}
+
+int^ x; // expected-error {{block pointer to non-function type is invalid}}
+int^^ x1; // expected-error {{block pointer to non-function type is invalid}}
+
+int test3() {
+	char *^ y; // expected-error {{block pointer to non-function type is invalid}}
+}
+