Skip to content

Commit 6f2e095

Browse files
committed
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. llvm-svn: 105643
1 parent ce21919 commit 6f2e095

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5238,7 +5238,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
52385238
// for the consumer of this Decl to know it doesn't own it.
52395239
// For our current ASTs this shouldn't be a problem, but will
52405240
// need to be changed with DeclGroups.
5241-
if (TUK == TUK_Reference || TUK == TUK_Friend)
5241+
if ((TUK == TUK_Reference && !PrevTagDecl->getFriendObjectKind()) ||
5242+
TUK == TUK_Friend)
52425243
return DeclPtrTy::make(PrevTagDecl);
52435244

52445245
// Diagnose attempts to redefine a tag.

clang/test/SemaCXX/friend.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ namespace test3 {
4747
friend const int getInt(int inInt = 0);
4848
};
4949
}
50+
51+
namespace test4 {
52+
class T4A {
53+
friend class T4B;
54+
55+
public:
56+
T4A(class T4B *);
57+
58+
protected:
59+
T4B *mB; // error here
60+
};
61+
62+
class T4B {};
63+
}

0 commit comments

Comments
 (0)