Much to my surprise, OverloadExprs can also point to function template decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127061 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3da647a..f97d1a8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4017,21 +4017,24 @@
bool HasViableZeroArgOverload = false;
for (OverloadExpr::decls_iterator it = AllOverloads.begin(),
DeclsEnd = AllOverloads.end(); it != DeclsEnd; ++it) {
- const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*it);
- QualType ResultTy = OverloadDecl->getResultType();
- if ((!IsArrow && ResultTy->isRecordType()) ||
- (IsArrow && ResultTy->isPointerType() &&
- ResultTy->getPointeeType()->isRecordType())) {
- ViableOverloads.addDecl(*it);
- if (OverloadDecl->getMinRequiredArguments() == 0) {
- HasViableZeroArgOverload = true;
+ // Our overload set may include TemplateDecls, which we'll ignore for the
+ // purposes of determining whether we can issue a '()' fixit.
+ if (const FunctionDecl *OverloadDecl = dyn_cast<FunctionDecl>(*it)) {
+ QualType ResultTy = OverloadDecl->getResultType();
+ if ((!IsArrow && ResultTy->isRecordType()) ||
+ (IsArrow && ResultTy->isPointerType() &&
+ ResultTy->getPointeeType()->isRecordType())) {
+ ViableOverloads.addDecl(*it);
+ if (OverloadDecl->getMinRequiredArguments() == 0) {
+ HasViableZeroArgOverload = true;
+ }
}
}
}
if (!HasViableZeroArgOverload || ViableOverloads.size() != 1) {
Diag(BaseExpr->getExprLoc(), diag::err_member_reference_needs_call)
- << 1 << 0
+ << (AllOverloads.size() > 1) << 0
<< BaseExpr->getSourceRange();
int ViableOverloadCount = ViableOverloads.size();
int I;
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 3c3eb04..68af415 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -135,4 +135,9 @@
int g3() {
return fun3.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it with no arguments?}}
}
+
+ template <typename T> S fun4();
+ int g4() {
+ return fun4.x; // expected-error{{base of member reference is a function; perhaps you meant to call it?}}
+ }
}