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;