aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp3
-rw-r--r--test/SemaCXX/friend.cpp14
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 03b2ef5643..249cbef38a 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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.
diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp
index ffad0e2b44..4f86d6a94d 100644
--- a/test/SemaCXX/friend.cpp
+++ b/test/SemaCXX/friend.cpp
@@ -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 {};
+}