Turn on -flax-vector-conversions by default, issue a warning whenever one is done. Add a -fnolax-vector-conversions option. Fixes PR2862.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63447 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 129967a..ddd5349 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2448,7 +2448,7 @@
     if (getLangOptions().LaxVectorConversions &&
         lhsType->isVectorType() && rhsType->isVectorType()) {
       if (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType))
-        return Compatible;
+        return IncompatibleVectors;
     }
     return Incompatible;
   }      
@@ -2599,13 +2599,17 @@
 
   // Handle the case of a vector & extvector type of the same size and element
   // type.  It would be nice if we only had one vector type someday.
-  if (getLangOptions().LaxVectorConversions)
-    if (const VectorType *LV = lhsType->getAsVectorType())
+  if (getLangOptions().LaxVectorConversions) {
+    // FIXME: Should we warn here?
+    if (const VectorType *LV = lhsType->getAsVectorType()) {
       if (const VectorType *RV = rhsType->getAsVectorType())
         if (LV->getElementType() == RV->getElementType() &&
-            LV->getNumElements() == RV->getNumElements())
+            LV->getNumElements() == RV->getNumElements()) {
           return lhsType->isExtVectorType() ? lhsType : rhsType;
-
+        }
+    }
+  }
+  
   // If the lhs is an extended vector and the rhs is a scalar of the same type
   // or a literal, promote the rhs to the vector type.
   if (const ExtVectorType *V = lhsType->getAsExtVectorType()) {
@@ -4359,6 +4363,9 @@
     // it can give a more specific diagnostic.
     DiagKind = diag::warn_incompatible_qualified_id;
     break;
+  case IncompatibleVectors:
+    DiagKind = diag::warn_incompatible_vectors;
+    break;
   case Incompatible:
     DiagKind = diag::err_typecheck_convert_incompatible;
     isInvalid = true;