diff options
author | Francois Pichet <pichet2000@gmail.com> | 2011-11-25 01:10:54 +0000 |
---|---|---|
committer | Francois Pichet <pichet2000@gmail.com> | 2011-11-25 01:10:54 +0000 |
commit | c8ff915c4bafe520548cc29d342951da23591ae1 (patch) | |
tree | c0d608c9ef1a453fb1b6e152c419e03fff7a889c /lib/Sema/SemaExpr.cpp | |
parent | 0ff64956629c03a8d99e14b5f84fc4d5f311e20f (diff) |
In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside a friend function definition at class scope.
Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext.
This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ef9d787fe4..e6e6e5f5e1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1511,8 +1511,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, // unqualified lookup. This is useful when (for example) the // original lookup would not have found something because it was a // dependent name. - for (DeclContext *DC = SS.isEmpty() ? CurContext : 0; - DC; DC = DC->getParent()) { + DeclContext *DC = SS.isEmpty() ? CurContext : 0; + while (DC) { if (isa<CXXRecordDecl>(DC)) { LookupQualifiedName(R, DC); @@ -1591,6 +1591,17 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, R.clear(); } + + // In Microsoft mode, if we are performing lookup from within a friend + // function definition declared at class scope then we must set + // DC to the lexical parent to be able to search into the parent + // class. + if (getLangOptions().MicrosoftMode && DC->isFunctionOrMethod() && + cast<FunctionDecl>(DC)->getFriendObjectKind() && + DC->getLexicalParent()->isRecord()) + DC = DC->getLexicalParent(); + else + DC = DC->getParent(); } // We didn't find anything, so try to correct for a typo. |