]> granicus.if.org Git - clang/commitdiff
When referring to a tag that was previously declared only as a friend,
authorDouglas Gregor <dgregor@apple.com>
Tue, 8 Jun 2010 21:27:36 +0000 (21:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 8 Jun 2010 21:27:36 +0000 (21:27 +0000)
build a new declaration for that tag type that will be visible for
future lookups of that tag.

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

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

index 03b2ef56430571dcdaa18a018b8086f3d57ce1b2..249cbef38a1fd50720ffa706244e55dd652772c7 100644 (file)
@@ -5238,7 +5238,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
           // 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.
index ffad0e2b44ef42f57ba1efee6cb4e84f09e5346f..4f86d6a94d6bb6fed790abbab9f5202ec6579fca 100644 (file)
@@ -47,3 +47,17 @@ namespace test3 {
     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 {};
+}