]> granicus.if.org Git - clang/commitdiff
[Sema] Fix lax conversion between non ext vectors
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 1 Aug 2017 19:05:25 +0000 (19:05 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 1 Aug 2017 19:05:25 +0000 (19:05 +0000)
r282968 introduced a regression due to the lack of proper testing.
Re-add lax conversion support between non ext vectors for compound
assignments and add a test for that.

rdar://problem/28639467

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309722 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/vector-cast.c

index ead80b61586acfd0b9187dd7787e0551d7248f8d..d3d7d8b67c70c0062192b4c3898375be2a756d77 100644 (file)
@@ -8288,7 +8288,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     // type. Note that this is already done by non-compound assignments in
     // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
     // <1 x T> -> T. The result is also a vector type.
-    } else if (OtherType->isExtVectorType() ||
+    } else if (OtherType->isExtVectorType() || OtherType->isVectorType() ||
                (OtherType->isScalarType() && VT->getNumElements() == 1)) {
       ExprResult *RHSExpr = &RHS;
       *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
index cf23eb2742c44133e7ded683baa423091493d506..2bdc00707d4cc99cb511ff39e70144a1858a91ef 100644 (file)
@@ -48,6 +48,9 @@ typedef float float2 __attribute__ ((vector_size (8)));
 typedef __attribute__((vector_size(8))) double float64x1_t;
 typedef __attribute__((vector_size(16))) double float64x2_t;
 float64x1_t vget_low_f64(float64x2_t __p0);
+typedef float float16 __attribute__((__vector_size__(16)));
+typedef signed int vSInt32 __attribute__((__vector_size__(16)));
+typedef unsigned int vUInt32 __attribute__((__vector_size__(16)));
 
 void f4() {
   float2 f2;
@@ -73,3 +76,8 @@ void f5() {
   v = ptr; // expected-error-re {{assigning to 'short_sizeof_pointer' (vector of {{[0-9]+}} 'short' values) from incompatible type 'void *'}}
   ptr = v; // expected-error {{assigning to 'void *' from incompatible type 'short_sizeof_pointer'}}
 }
+
+void f6(vSInt32 a0) {
+  vUInt32 counter = (float16){0.0f, 0.0f, 0.0f, 0.0f}; // expected-warning {{incompatible vector types initializing 'vUInt32' (vector of 4 'unsigned int' values) with an expression of type 'float16' (vector of 4 'float' values)}}
+  counter -= a0;
+}