]> granicus.if.org Git - clang/commitdiff
Disallow captured arrays in blocks as well. Radar 7438948.
authorMike Stump <mrs@apple.com>
Tue, 5 Jan 2010 03:10:36 +0000 (03:10 +0000)
committerMike Stump <mrs@apple.com>
Tue, 5 Jan 2010 03:10:36 +0000 (03:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92677 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1f8934e076a2f29f21bd3c402c590ffbe47f6edb..fac4f7e1a5d0eb9a38190fcbc2e8be1fd39550b6 100644 (file)
@@ -1723,6 +1723,8 @@ def err_unexpected_interface : Error<
 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<
index f0d39dde9f458caecb8eac6fbcfc78d17b0ac0de..3d2ee742789fa1ac88fb94bfc72a9ed787d54bd3 100644 (file)
@@ -1537,6 +1537,12 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
       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.
index bc30552302e5d6351c6093f11aeb1ca83f9dc5c7..4179eda5e75b632968a95c91b8f1814ae86b17d9 100644 (file)
@@ -208,3 +208,11 @@ void test20() {
     (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}}
+  }();
+}