diff options
Diffstat (limited to 'lib/Sema/IdentifierResolver.cpp')
-rw-r--r-- | lib/Sema/IdentifierResolver.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index 6f5ddca20b..d44c1fb926 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -302,6 +302,14 @@ static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New) { // If the declarations are redeclarations of each other, keep the newest one. if (Existing->getCanonicalDecl() == New->getCanonicalDecl()) { + // If either of these is the most recent declaration, use it. + Decl *MostRecent = Existing->getMostRecentDecl(); + if (Existing == MostRecent) + return DMK_Ignore; + + if (New == MostRecent) + return DMK_Replace; + // If the existing declaration is somewhere in the previous declaration // chain of the new declaration, then prefer the new declaration. for (Decl::redecl_iterator RD = New->redecls_begin(), |