]> granicus.if.org Git - clang/commitdiff
Skip through transparent contexts when deciding where to add a friend function.
authorNick Lewycky <nicholas@mxc.ca>
Fri, 16 Mar 2012 19:51:19 +0000 (19:51 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 16 Mar 2012 19:51:19 +0000 (19:51 +0000)
This fixes g++.dg/parse/friend5.C.

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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/friend.cpp

index 79a5d4c98c57e0b7b7764a593220e98c361beb59..c8c3af3cd5417dd8444e55d15c6ab13c7b182f28 100644 (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);
index b1ef220e534c823c5a2eef680ea3ef7381a75abc..c5b11eb5a33854b3eebde11c1ae8eb65c4f88350 100644 (file)
@@ -130,3 +130,11 @@ namespace test6_3 {
     v.f();
   }
 }
+
+namespace test7 {
+  extern "C" {
+    class X {
+      friend int f() { return 42; }
+    };
+  }
+}