aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
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
commit49e2b8e2e5d096851b5135ea5aed222e8aa95bde (patch)
tree94726830e0446a921e15f50cdb0b554c2562403d /lib/Sema/SemaDecl.cpp
parent19aeac6ea4897c542b21c9f53a0a51762d8ddf83 (diff)
Fix for PR5489: don't skip the complete type requrirement for variable
definitions just because the type happens to be an array type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88752 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index fa31cc5ddb..65e839b04d 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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;