diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 86222ffe147..113283a6446 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4331,6 +4331,11 @@ CreateNewDecl: if (TUK == TUK_Friend) { // Friend tag decls are visible in fairly strange ways. if (!CurContext->isDependentContext()) { + // We might be replacing an existing declaration in the lookup tables; + // if so, borrow its access specifier. + if (PrevDecl) + New->setAccess(PrevDecl->getAccess()); + DeclContext *DC = New->getDeclContext()->getLookupContext(); DC->makeDeclVisibleInContext(New, /* Recoverable = */ false); if (Scope *EnclosingScope = getScopeForDeclContext(S, DC)) |