Merge all the 'assignment' diagnostic code into one routine, decloning 
it from several places.  This merges the diagnostics, making them more
uniform and fewer in number. This also simplifies and cleans up the code.

Some highlights:
1. This removes a bunch of very-similar diagnostics.
2. This renames AssignmentCheckResult -> AssignConvertType
3. This merges PointerFromInt + IntFromPointer which were always treated the same.
4. This updates a bunch of test cases that have minor changes to the produced diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45589 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 1165e52..07b3d71 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -364,53 +364,13 @@
     return true;
   }
   
-  AssignmentCheckResult result;
   // Get the type before calling CheckSingleAssignmentConstraints(), since
   // it can promote the expression.
-  QualType rhsType = Init->getType(); 
+  QualType InitType = Init->getType(); 
   
-  result = CheckSingleAssignmentConstraints(DeclType, Init);
-  
-  // decode the result (notice that extensions still return a type).
-  switch (result) {
-  case Compatible:
-    break;
-  case Incompatible:
-    // FIXME: tighten up this check which should allow:
-    // char s[] = "abc", which is identical to char s[] = { 'a', 'b', 'c' };
-    if (rhsType == Context.getPointerType(Context.CharTy))
-      break;
-    Diag(Init->getLocStart(), diag::err_typecheck_assign_incompatible, 
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    return true;
-  case PointerFromInt:
-    Diag(Init->getLocStart(), diag::ext_typecheck_assign_pointer_int,
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    break;
-  case IntFromPointer: 
-    Diag(Init->getLocStart(), diag::ext_typecheck_assign_pointer_int, 
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    break;
-  case FunctionVoidPointer:
-    Diag(Init->getLocStart(), diag::ext_typecheck_assign_pointer_void_func, 
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    break;
-  case IncompatiblePointer:
-    Diag(Init->getLocStart(), diag::ext_typecheck_assign_incompatible_pointer,
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    break;
-  case CompatiblePointerDiscardsQualifiers:
-    Diag(Init->getLocStart(), diag::ext_typecheck_assign_discards_qualifiers,
-         DeclType.getAsString(), rhsType.getAsString(), 
-         Init->getSourceRange());
-    break;
-  }
-  return false;
+  AssignConvertType ConvTy = CheckSingleAssignmentConstraints(DeclType, Init);
+  return DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
+                                  InitType, Init, "initializing");
 }
 
 bool Sema::CheckInitExpr(Expr *expr, InitListExpr *IList, unsigned slot,