summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-09-02 19:32:14 +0000
committerJohn McCall <rjmccall@apple.com>2009-09-02 19:32:14 +0000
commitf8bd861ce97c4bcf7a5cf77c12aa0f3235b1ef61 (patch)
tree1fff8a7a6215049e119e9b4a1e777db98c69e264 /clang
parenta7e8799c729e66a5777855e8954c04f5e5ab81c9 (diff)
downloadbcm5719-llvm-f8bd861ce97c4bcf7a5cf77c12aa0f3235b1ef61.tar.gz
bcm5719-llvm-f8bd861ce97c4bcf7a5cf77c12aa0f3235b1ef61.zip
Borrow a friend class's previous declaration's access specifier regardless of
whether the current context is dependent. Thanks to Anders for pointing this out. llvm-svn: 80828
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp3
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 113283a6446..e7a327805a0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4329,13 +4329,13 @@ CreateNewDecl:
// If this has an identifier, add it to the scope stack.
if (TUK == TUK_Friend) {
+ // We might be replacing an existing declaration in the lookup tables;
+ // if so, borrow its access specifier.
+ if (PrevDecl)
+ New->setAccess(PrevDecl->getAccess());
+
// 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))
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index 4434d483890..3777485e1ae 100644
--- a/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -27,6 +27,9 @@ public:
value_ += b.value_;
return *this;
}
+
+ class Representation {};
+ friend class Representation;
};
class A {
OpenPOWER on IntegriCloud