Skip through transparent contexts when deciding where to add a friend function.

This fixes g++.dg/parse/friend5.C.

llvm-svn: 152938
This commit is contained in:
Nick Lewycky 2012-03-16 19:51:19 +00:00
parent 7bfe2b5a4a
commit af0cc7fd27
2 changed files with 9 additions and 1 deletions

View File

@ -10060,7 +10060,7 @@ Decl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D,
// declarations should stop at the nearest enclosing namespace,
// not that they should only consider the nearest enclosing
// namespace.
while (DC->isRecord())
while (DC->isRecord() || DC->isTransparentContext())
DC = DC->getParent();
LookupQualifiedName(Previous, DC);

View File

@ -130,3 +130,11 @@ namespace test6_3 {
v.f();
}
}
namespace test7 {
extern "C" {
class X {
friend int f() { return 42; }
};
}
}