diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-01-14 02:27:38 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-01-14 02:27:38 +0000 |
commit | ce12ed20c60bd16c44aad271ca0fd9cf1ec00310 (patch) | |
tree | 6d4aae9e7e4d1f63ac873504019b7f554f15267a /clang/lib/Sema/SemaDecl.cpp | |
parent | 2eb4d4468f1fe5326fef536c660b9246c74ce41d (diff) | |
download | bcm5719-llvm-ce12ed20c60bd16c44aad271ca0fd9cf1ec00310.tar.gz bcm5719-llvm-ce12ed20c60bd16c44aad271ca0fd9cf1ec00310.zip |
Sema: Check type compatibility with the most recent decl when merging
We would check the type information from the declaration found by lookup
but we would neglect checking compatibility with the most recent
declaration. This would make it possible for us to not correctly
diagnose inconsistencies with declarations which were made in a
different scope.
llvm-svn: 225934
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1bf57f6cee7..b967e17148d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3239,8 +3239,15 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { } // Merge the types. - MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous)); + VarDecl *MostRecent = Old->getMostRecentDecl(); + if (MostRecent != Old) { + MergeVarDeclTypes(New, MostRecent, + mergeTypeWithPrevious(*this, New, MostRecent, Previous)); + if (New->isInvalidDecl()) + return; + } + MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous)); if (New->isInvalidDecl()) return; |