Much to my surprise, OverloadExprs can also point to function template decls.

llvm-svn: 127061
This commit is contained in:
Matt Beaumont-Gay 2011-03-05 02:42:30 +00:00
parent 6f9a8f85d7
commit f8bb45f14d
2 changed files with 17 additions and 9 deletions

View File

@ -4017,21 +4017,24 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
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;

View File

@ -135,4 +135,9 @@ namespace PR9025 {
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?}}
}
}