Avoid calling mergeTypes in C++.  I think these are the correct C++ 
alternatives, but please correct me if I'm wrong.

I eventually plan to assert in mergeTypes that we aren't in C++ mode 
because composite types are fundamentally not a part of C++. The 
remaining callers for code in the regression tests are 
Sema::WarnConflictingTypedMethods and CodeGenFunction::EmitFunctionProlog;
I'm not quite sure what the correct approach is for those callers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71946 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 077658c..2847dc1 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -916,7 +916,13 @@
   MergeAttributes(New, Old, Context);
 
   // Merge the types
-  QualType MergedT = Context.mergeTypes(New->getType(), Old->getType());
+  QualType MergedT;
+  if (getLangOptions().CPlusPlus) {
+    if (Context.hasSameType(New->getType(), Old->getType()))
+      MergedT = New->getType();
+  } else {
+    MergedT = Context.mergeTypes(New->getType(), Old->getType());
+  }
   if (MergedT.isNull()) {
     Diag(New->getLocation(), diag::err_redefinition_different_type) 
       << New->getDeclName();