]> granicus.if.org Git - clang/commitdiff
Allow splat casts for OCU vector assignments & add some comments.
authorNate Begeman <natebegeman@mac.com>
Sun, 30 Dec 2007 01:45:55 +0000 (01:45 +0000)
committerNate Begeman <natebegeman@mac.com>
Sun, 30 Dec 2007 01:45:55 +0000 (01:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45442 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index 99426a29fb12c7c3eae20954895561802d74af03..014e457b9760cd606d5e6ae91b9ac86eaf8d112c 100644 (file)
@@ -1129,7 +1129,15 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
         if (lhsType.getCanonicalType() != rhsType.getCanonicalType())
           return Incompatible;
       } else {
+        // For OCUVector, allow vector splats; float -> <n x float>
+        if (const OCUVectorType *LV = lhsType->getAsOCUVectorType()) {
+          if (LV->getElementType().getTypePtr() == rhsType.getTypePtr())
+            return Compatible;
+        }
         if (lhsType->isVectorType() && rhsType->isVectorType()) {
+          // If LHS and RHS are both integer or both floating point types, and
+          // the total vector length is the same, allow the conversion.  This is
+          // a bitcast; no bits are changed but the result type is different.
           if ((lhsType->isIntegerType() && rhsType->isIntegerType()) ||
               (lhsType->isRealFloatingType() && 
                rhsType->isRealFloatingType())) {