diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-14 03:40:14 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-14 03:40:14 +0000 |
commit | 49e2b8e2e5d096851b5135ea5aed222e8aa95bde (patch) | |
tree | 94726830e0446a921e15f50cdb0b554c2562403d /lib/Sema/SemaDecl.cpp | |
parent | 19aeac6ea4897c542b21c9f53a0a51762d8ddf83 (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.cpp | 9 |
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; |