[cfe-commits] r152938 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/friend.cpp

Nick Lewycky nicholas at mxc.ca
Fri Mar 16 12:51:19 PDT 2012


Author: nicholas
Date: Fri Mar 16 14:51:19 2012
New Revision: 152938

URL: http://llvm.org/viewvc/llvm-project?rev=152938&view=rev
Log:
Skip through transparent contexts when deciding where to add a friend function.
This fixes g++.dg/parse/friend5.C.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/friend.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=152938&r1=152937&r2=152938&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Mar 16 14:51:19 2012
@@ -10060,7 +10060,7 @@
       // 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);

Modified: cfe/trunk/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend.cpp?rev=152938&r1=152937&r2=152938&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend.cpp Fri Mar 16 14:51:19 2012
@@ -130,3 +130,11 @@
     v.f();
   }
 }
+
+namespace test7 {
+  extern "C" {
+    class X {
+      friend int f() { return 42; }
+    };
+  }
+}





More information about the cfe-commits mailing list