]> granicus.if.org Git - clang/commitdiff
Allow qualifiers on blocks. Radar 6441502
authorMike Stump <mrs@apple.com>
Thu, 7 May 2009 21:56:17 +0000 (21:56 +0000)
committerMike Stump <mrs@apple.com>
Thu, 7 May 2009 21:56:17 +0000 (21:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71183 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/Sema/block-misc.c

index 6f9818f3507fb9f8943a434aef109a7ddedee637..08a5770196f96c89d7775078b1bac99b6e149812 100644 (file)
@@ -666,12 +666,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
       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);
index 6c62376dc402f2cbc0eee94167beb6f27fc52394..93ca3c49d42591697f814369075b7990e8e6571f 100644 (file)
@@ -180,3 +180,8 @@ void test17() {
   (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}}
+}