summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-11-14 03:40:14 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-11-14 03:40:14 +0000
commitc9827d1ad36b9dcffb53f2cea82aec5e7e6636bf (patch)
tree0c786e7fb4fcc627fc4ad2d8ad2d4670dcc9731a /clang/lib/Sema
parentbf3f322034bdf663665675629c887df00556c726 (diff)
downloadbcm5719-llvm-c9827d1ad36b9dcffb53f2cea82aec5e7e6636bf.tar.gz
bcm5719-llvm-c9827d1ad36b9dcffb53f2cea82aec5e7e6636bf.zip
Fix for PR5489: don't skip the complete type requrirement for variable
definitions just because the type happens to be an array type. llvm-svn: 88752
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fa31cc5ddb0..65e839b04db 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3279,8 +3279,13 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
return;
}
- if (!VDecl->getType()->isArrayType() &&
- RequireCompleteType(VDecl->getLocation(), VDecl->getType(),
+ // A definition must end up with a complete type, which means it must be
+ // complete with the restriction that an array type might be completed by the
+ // initializer; note that later code assumes this restriction.
+ QualType BaseDeclType = VDecl->getType();
+ if (const ArrayType *Array = Context.getAsIncompleteArrayType(BaseDeclType))
+ BaseDeclType = Array->getElementType();
+ if (RequireCompleteType(VDecl->getLocation(), BaseDeclType,
diag::err_typecheck_decl_incomplete_type)) {
RealDecl->setInvalidDecl();
return;
OpenPOWER on IntegriCloud