Allow qualifiers on blocks.  Radar 6441502


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71183 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 6f9818f..08a5770 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -666,12 +666,11 @@
       if (!LangOpts.Blocks)
         Diag(DeclType.Loc, diag::err_blocks_disable);
         
-      if (DeclType.Cls.TypeQuals)
-        Diag(D.getIdentifierLoc(), diag::err_qualified_block_pointer_type);
       if (!T.getTypePtr()->isFunctionType())
         Diag(D.getIdentifierLoc(), diag::err_nonfunction_block_type);
       else
-        T = Context.getBlockPointerType(T);
+        T = (Context.getBlockPointerType(T)
+             .getQualifiedType(DeclType.Cls.TypeQuals));
       break;
     case DeclaratorChunk::Pointer:
       T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index 6c62376..93ca3c4 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -180,3 +180,8 @@
   (void)(1 < bp); // expected-error {{invalid operands to binary expression}}
   (void)(0 < bp); // expected-error {{invalid operands to binary expression}}
 }
+
+void test18() {
+  void (^const  blockA)(void) = ^{ };
+  blockA = ^{ }; // expected-error {{read-only variable is not assignable}}
+}