[cfe-commits] r60645 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Anders Carlsson
andersca at mac.com
Sat Dec 6 16:49:49 PST 2008
Author: andersca
Date: Sat Dec 6 18:49:48 2008
New Revision: 60645
URL: http://llvm.org/viewvc/llvm-project?rev=60645&view=rev
Log:
Pass the VLA size expr range to the VLA diags
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=60645&r1=60644&r2=60645&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Dec 6 18:49:48 2008
@@ -1928,17 +1928,27 @@
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();
}
}
More information about the cfe-commits
mailing list