aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaExpr.cpp6
-rw-r--r--test/Sema/block-misc.c8
3 files changed, 16 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 1f8934e076..fac4f7e1a5 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f0d39dde9f..3d2ee74278 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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.
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index bc30552302..4179eda5e7 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -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}}
+ }();
+}