aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp4
-rw-r--r--test/SemaCXX/friend.cpp9
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index fa3a4047e5..8efd49580f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3675,7 +3675,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
}
if (D.getCXXScopeSpec().isSet() && !NewFD->isInvalidDecl()) {
- if (!CurContext->isRecord()) {
+ if (isFriend || !CurContext->isRecord()) {
// Fake up an access specifier if it's supposed to be a class member.
if (!Redeclaration && isa<CXXRecordDecl>(NewFD->getDeclContext()))
NewFD->setAccess(AS_public);
@@ -3722,7 +3722,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Diag((*Func)->getLocation(), diag::note_member_def_close_match);
}
}
- } else if (!isFriend) {
+ } else {
// The user provided a superfluous scope specifier inside a class definition:
//
// class X {
diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp
index 30abcbbeaa..e35c500e9a 100644
--- a/test/SemaCXX/friend.cpp
+++ b/test/SemaCXX/friend.cpp
@@ -62,3 +62,12 @@ namespace test4 {
class T4B {};
}
+
+namespace rdar8529993 {
+struct A { ~A(); }; // expected-note {{nearly matches}}
+
+struct B : A
+{
+ template<int> friend A::~A(); // expected-error {{does not match}}
+};
+}