]> granicus.if.org Git - clang/commitdiff
Borrow a friend class's previous declaration's access specifier regardless of
authorJohn McCall <rjmccall@apple.com>
Wed, 2 Sep 2009 19:32:14 +0000 (19:32 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 2 Sep 2009 19:32:14 +0000 (19:32 +0000)
whether the current context is dependent.

Thanks to Anders for pointing this out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80828 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/CXX/temp/temp.decls/temp.friend/p1.cpp

index 113283a64464b10ac7f01afad3dcfd5f0e78cdb8..e7a327805a09f5f758032f4054dea2c4a29ee831 100644 (file)
@@ -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))
index 4434d483890293b34133c4aba264302355a68dc7..3777485e1ae12d07ad0384a1ecb09f3d60fa996c 100644 (file)
@@ -27,6 +27,9 @@ public:
     value_ += b.value_;
     return *this;
   }
+
+  class Representation {};
+  friend class Representation;
 };
 
 class A {