Recommit r102215, this time being more careful to only set the "principal
declaration" (i.e. the only which will actually be looked up) to have the
non-member-operator bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102231 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index fe60be0..d14ea1a 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1124,22 +1124,27 @@
isExplicitSpecialization, Redeclaration,
/*FIXME:*/OverloadableAttrRequired);
+ NamedDecl *PrincipalDecl = (TemplateParams
+ ? cast<NamedDecl>(FunctionTemplate)
+ : Function);
+
// If the original function was part of a friend declaration,
// inherit its namespace state and add it to the owner.
if (isFriend) {
- NamedDecl *ToFriendD = 0;
NamedDecl *PrevDecl;
- if (TemplateParams) {
- ToFriendD = cast<NamedDecl>(FunctionTemplate);
+ if (TemplateParams)
PrevDecl = FunctionTemplate->getPreviousDeclaration();
- } else {
- ToFriendD = Function;
+ else
PrevDecl = Function->getPreviousDeclaration();
- }
- ToFriendD->setObjectOfFriendDecl(PrevDecl != NULL);
- DC->makeDeclVisibleInContext(ToFriendD, /*Recoverable=*/ false);
+
+ PrincipalDecl->setObjectOfFriendDecl(PrevDecl != 0);
+ DC->makeDeclVisibleInContext(PrincipalDecl, /*Recoverable=*/ false);
}
+ if (Function->isOverloadedOperator() && !DC->isRecord() &&
+ PrincipalDecl->isInIdentifierNamespace(Decl::IDNS_Ordinary))
+ PrincipalDecl->setNonMemberOperator();
+
return Function;
}