diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-08-10 15:20:13 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-08-10 15:20:13 +0000 |
| commit | 84e37356d6377bd92d7858da68fc754fa4e0f9d9 (patch) | |
| tree | 87e7c988517180be468ab55b43c088a99854739f /clang/lib | |
| parent | b3dd1e0889fa8d41ed30620b37800d58228cba94 (diff) | |
| download | bcm5719-llvm-84e37356d6377bd92d7858da68fc754fa4e0f9d9.tar.gz bcm5719-llvm-84e37356d6377bd92d7858da68fc754fa4e0f9d9.zip | |
Sema::CheckForFileScopedRedefinitions(): Make sure tentative decls of incomplete array types are completed (and diagnosed properly).
llvm-svn: 54612
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c776a5bfa5c..df4add2ea3e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -391,6 +391,7 @@ bool Sema::isTentativeDefinition(VarDecl *VD) { /// when dealing with C "tentative" external object definitions (C99 6.9.2). void Sema::CheckForFileScopedRedefinitions(Scope *S, VarDecl *VD) { bool VDIsTentative = isTentativeDefinition(VD); + bool VDIsIncompleteArray = VD->getType()->isIncompleteArrayType(); for (IdentifierResolver::iterator I = IdResolver.begin(VD->getIdentifier(), @@ -399,6 +400,14 @@ void Sema::CheckForFileScopedRedefinitions(Scope *S, VarDecl *VD) { if (*I != VD && IdResolver.isDeclInScope(*I, VD->getDeclContext(), S)) { VarDecl *OldDecl = dyn_cast<VarDecl>(*I); + // Handle the following case: + // int a[10]; + // int a[]; - the code below makes sure we set the correct type. + // int a[11]; - this is an error, size isn't 10. + if (OldDecl && VDIsTentative && VDIsIncompleteArray && + OldDecl->getType()->isConstantArrayType()) + VD->setType(OldDecl->getType()); + // Check for "tentative" definitions. We can't accomplish this in // MergeVarDecl since the initializer hasn't been attached. if (!OldDecl || isTentativeDefinition(OldDecl) || VDIsTentative) |

