[cfe-commits] r92677 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/block-misc.c

Mike Stump mrs at apple.com
Mon Jan 4 19:10:36 PST 2010


Author: mrs
Date: Mon Jan  4 21:10:36 2010
New Revision: 92677

URL: http://llvm.org/viewvc/llvm-project?rev=92677&view=rev
Log:
Disallow captured arrays in blocks as well.  Radar 7438948.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/block-misc.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=92677&r1=92676&r2=92677&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan  4 21:10:36 2010
@@ -1723,6 +1723,8 @@
 def err_ref_non_value : Error<"%0 does not refer to a value">;
 def err_ref_vm_type : Error<
   "cannot refer to declaration with a variably modified type inside block">;
+def err_ref_array_type : Error<
+  "cannot refer to declaration with an array type inside block">;
 def err_property_not_found : Error<
   "property %0 not found on object of type %1">;
 def err_duplicate_property : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=92677&r1=92676&r2=92677&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan  4 21:10:36 2010
@@ -1537,6 +1537,12 @@
       return ExprError();
     }
 
+    if (VD->getType()->isArrayType()) {
+      Diag(Loc, diag::err_ref_array_type);
+      Diag(D->getLocation(), diag::note_declared_at);
+      return ExprError();
+    }
+
     MarkDeclarationReferenced(Loc, VD);
     QualType ExprTy = VD->getType().getNonReferenceType();
     // The BlocksAttr indicates the variable is bound by-reference.

Modified: cfe/trunk/test/Sema/block-misc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=92677&r1=92676&r2=92677&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-misc.c (original)
+++ cfe/trunk/test/Sema/block-misc.c Mon Jan  4 21:10:36 2010
@@ -208,3 +208,11 @@
     (void)(vm+1);  // expected-error {{cannot refer to declaration with a variably modified type inside block}}
   }();
 }
+
+void test21() {
+  int a[7]; // expected-note {{declared at}}
+  a[1] = 1;
+  ^{
+    (void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
+  }();
+}





More information about the cfe-commits mailing list