diff options
author | John McCall <rjmccall@apple.com> | 2012-08-24 22:54:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-08-24 22:54:02 +0000 |
commit | 8bddeb57d134c0e5f14e319271aa9015886a8ac7 (patch) | |
tree | 98a6b50c192f52623a0645953de077d613d585ab /lib/Sema/SemaAccess.cpp | |
parent | e16acd3817e501ee2bcf5f631b6911021fa88ba7 (diff) |
When computing the effective context for access control,
make sure we walk up the DC chain for the current context,
rather than allowing ourselves to get switched over to the
canonical DC chain. Fixes PR13642.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162616 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAccess.cpp')
-rw-r--r-- | lib/Sema/SemaAccess.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp index ed72a5600b..58b1a51ae5 100644 --- a/lib/Sema/SemaAccess.cpp +++ b/lib/Sema/SemaAccess.cpp @@ -97,14 +97,19 @@ struct EffectiveContext { // functions (which can gain privileges through friendship), but we // take that as an oversight. while (true) { + // We want to add canonical declarations to the EC lists for + // simplicity of checking, but we need to walk up through the + // actual current DC chain. Otherwise, something like a local + // extern or friend which happens to be the canonical + // declaration will really mess us up. + if (isa<CXXRecordDecl>(DC)) { - CXXRecordDecl *Record = cast<CXXRecordDecl>(DC)->getCanonicalDecl(); - Records.push_back(Record); + CXXRecordDecl *Record = cast<CXXRecordDecl>(DC); + Records.push_back(Record->getCanonicalDecl()); DC = Record->getDeclContext(); } else if (isa<FunctionDecl>(DC)) { - FunctionDecl *Function = cast<FunctionDecl>(DC)->getCanonicalDecl(); - Functions.push_back(Function); - + FunctionDecl *Function = cast<FunctionDecl>(DC); + Functions.push_back(Function->getCanonicalDecl()); if (Function->getFriendObjectKind()) DC = Function->getLexicalDeclContext(); else |