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

Douglas Gregor dgregor at apple.com
Tue Jun 8 14:27:37 PDT 2010


Author: dgregor
Date: Tue Jun  8 16:27:36 2010
New Revision: 105643

URL: http://llvm.org/viewvc/llvm-project?rev=105643&view=rev
Log:
When referring to a tag that was previously declared only as a friend, 
build a new declaration for that tag type that will be visible for
future lookups of that tag.


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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=105643&r1=105642&r2=105643&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun  8 16:27:36 2010
@@ -5238,7 +5238,8 @@
           // for the consumer of this Decl to know it doesn't own it.
           // For our current ASTs this shouldn't be a problem, but will
           // need to be changed with DeclGroups.
-          if (TUK == TUK_Reference || TUK == TUK_Friend)
+          if ((TUK == TUK_Reference && !PrevTagDecl->getFriendObjectKind()) ||
+              TUK == TUK_Friend)
             return DeclPtrTy::make(PrevTagDecl);
 
           // Diagnose attempts to redefine a tag.

Modified: cfe/trunk/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend.cpp?rev=105643&r1=105642&r2=105643&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend.cpp Tue Jun  8 16:27:36 2010
@@ -47,3 +47,17 @@
     friend const int getInt(int inInt = 0);
   };
 }
+
+namespace test4 {
+  class T4A {
+    friend class T4B;
+  
+  public:
+    T4A(class T4B *);
+
+  protected:
+    T4B *mB;          // error here
+  };
+ 
+  class T4B {};
+}





More information about the cfe-commits mailing list