Minor fixups for auto deduction of initializer lists.

Fix some review comments.
Add a test for deduction when std::initializer_list isn't available yet.
Fix redundant error messages. This fixes and outstanding FIXME too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148735 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 0d74f24..adc6994 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -3376,20 +3376,18 @@
 /// dependent. This will be set to null if deduction succeeded, but auto
 /// substitution failed; the appropriate diagnostic will already have been
 /// produced in that case.
-///
-/// \returns true if deduction succeeded, false if it failed.
-bool
+Sema::DeduceAutoResult
 Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *&Init,
                      TypeSourceInfo *&Result) {
   if (Init->getType()->isNonOverloadPlaceholderType()) {
     ExprResult result = CheckPlaceholderExpr(Init);
-    if (result.isInvalid()) return false;
+    if (result.isInvalid()) return DAR_FailedAlreadyDiagnosed;
     Init = result.take();
   }
 
   if (Init->isTypeDependent()) {
     Result = Type;
-    return true;
+    return DAR_Succeeded;
   }
 
   SourceLocation Loc = Init->getExprLoc();
@@ -3418,7 +3416,7 @@
   if (AdjustFunctionParmAndArgTypesForDeduction(*this, &TemplateParams,
                                                 FuncParam, InitType, Init,
                                                 TDF))
-    return false;
+    return DAR_Failed;
 
   TemplateDeductionInfo Info(Context, Loc);
 
@@ -3428,22 +3426,22 @@
       if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
                                              InitList->getInit(i)->getType(),
                                              Info, Deduced, TDF))
-        return false;
+        return DAR_Failed;
     }
   } else {
     if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
                                            InitType, Info, Deduced, TDF))
-      return false;
+      return DAR_Failed;
   }
 
   QualType DeducedType = Deduced[0].getAsType();
   if (DeducedType.isNull())
-    return false;
+    return DAR_Failed;
 
   if (InitList) {
     DeducedType = BuildStdInitializerList(DeducedType, Loc);
     if (DeducedType.isNull())
-      return false;
+      return DAR_FailedAlreadyDiagnosed;
   }
 
   Result = SubstituteAutoTransform(*this, DeducedType).TransformType(Type);
@@ -3455,10 +3453,10 @@
                                     Sema::OriginalCallArg(FuncParam,0,InitType),
                                     Result->getType())) {
     Result = 0;
-    return false;
+    return DAR_Failed;
   }
 
-  return true;
+  return DAR_Succeeded;
 }
 
 void Sema::DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init) {