[cfe-commits] r80750 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CXX/class/class.friend/p1.cpp
John McCall
rjmccall at apple.com
Tue Sep 1 19:15:18 PDT 2009
Author: rjmccall
Date: Tue Sep 1 21:15:17 2009
New Revision: 80750
URL: http://llvm.org/viewvc/llvm-project?rev=80750&view=rev
Log:
When adding a friend class declaration to the lookup tables, use the access specifier
of any previous declaration in case we replace it in a class's declaration table.
Fixes bug 4858. This sort of thing makes me reconsider putting friend declarations in
declaration lists.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/class/class.friend/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=80750&r1=80749&r2=80750&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 1 21:15:17 2009
@@ -4331,6 +4331,11 @@
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))
Modified: cfe/trunk/test/CXX/class/class.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.friend/p1.cpp?rev=80750&r1=80749&r2=80750&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class/class.friend/p1.cpp Tue Sep 1 21:15:17 2009
@@ -61,6 +61,10 @@
typedef void ftypedef();
friend ftypedef typedeffed_function; // okay (because it's not declared as a member)
+
+ class facet;
+ friend class facet; // should not assert
+ class facet {};
};
A::UndeclaredSoFar y; // expected-error {{ unknown type name 'UndeclaredSoFar' }}
More information about the cfe-commits
mailing list