summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-12-07 00:49:48 +0000
committerAnders Carlsson <andersca@mac.com>2008-12-07 00:49:48 +0000
commita1a9c28d30d6e471a24e8fbf272bde736574f7b4 (patch)
tree9ce5f5d485bb86afe19560f344235c0a4603707a /clang/lib/Sema/SemaDecl.cpp
parentccb9c3370aea525b09ed0a132bd2adf6c917b566 (diff)
downloadbcm5719-llvm-a1a9c28d30d6e471a24e8fbf272bde736574f7b4.tar.gz
bcm5719-llvm-a1a9c28d30d6e471a24e8fbf272bde736574f7b4.zip
Pass the VLA size expr range to the VLA diags
llvm-svn: 60645
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4d01a2d52c6..f125cb270e2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1928,17 +1928,27 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
QualType T = IDecl->getType();
if (T->isVariableArrayType()) {
+ const VariableArrayType *VAT =
+ cast<VariableArrayType>(T.getUnqualifiedType());
+
+ // FIXME: This won't give the correct result for
+ // int a[10][n];
+ SourceRange SizeRange = VAT->getSizeExpr()->getSourceRange();
if (IDecl->isFileVarDecl()) {
- Diag(IDecl->getLocation(), diag::err_vla_decl_in_file_scope);
+ Diag(IDecl->getLocation(), diag::err_vla_decl_in_file_scope) <<
+ SizeRange;
+
IDecl->setInvalidDecl();
} else {
// C99 6.7.5.2p2: If an identifier is declared to be an object with
// static storage duration, it shall not have a variable length array.
if (IDecl->getStorageClass() == VarDecl::Static) {
- Diag(IDecl->getLocation(), diag::err_vla_decl_has_static_storage);
+ Diag(IDecl->getLocation(), diag::err_vla_decl_has_static_storage)
+ << SizeRange;
IDecl->setInvalidDecl();
} else if (IDecl->getStorageClass() == VarDecl::Extern) {
- Diag(IDecl->getLocation(), diag::err_vla_decl_has_extern_linkage);
+ Diag(IDecl->getLocation(), diag::err_vla_decl_has_extern_linkage)
+ << SizeRange;
IDecl->setInvalidDecl();
}
}
OpenPOWER on IntegriCloud