From: Nick Lewycky Date: Fri, 16 Mar 2012 19:51:19 +0000 (+0000) Subject: Skip through transparent contexts when deciding where to add a friend function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c6fde5ac9c4a696baaa637a7fb6d83fe91e1e09;p=clang Skip through transparent contexts when deciding where to add a friend function. This fixes g++.dg/parse/friend5.C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152938 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 79a5d4c98c..c8c3af3cd5 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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); diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp index b1ef220e53..c5b11eb5a3 100644 --- a/test/SemaCXX/friend.cpp +++ b/test/SemaCXX/friend.cpp @@ -130,3 +130,11 @@ namespace test6_3 { v.f(); } } + +namespace test7 { + extern "C" { + class X { + friend int f() { return 42; } + }; + } +}