]> granicus.if.org Git - clang/commitdiff
Revert "[OpenCL] An error shall occur if any scalar operand has greater rank than...
authorRenato Golin <renato.golin@linaro.org>
Fri, 26 May 2017 15:32:45 +0000 (15:32 +0000)
committerRenato Golin <renato.golin@linaro.org>
Fri, 26 May 2017 15:32:45 +0000 (15:32 +0000)
This reverts commit r303986 as it broke all ARM and AArch64 buildbots...

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/7007
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/6705
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/7509
etc.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaOpenCL/arithmetic-conversions.cl [deleted file]
test/SemaOpenCL/cond.cl

index 02892dbb6f68582c7404cdc704155c3a0b8a3479..3f17959fc7b3f58c2aa296d4a0b77c7a765ef880 100644 (file)
@@ -8314,9 +8314,6 @@ def err_opencl_bitfields : Error<
   "bit-fields are not supported in OpenCL">;
 def err_opencl_vla : Error<
   "variable length arrays are not supported in OpenCL">;
-def err_opencl_scalar_type_rank_greater_than_vector_type : Error<
-    "scalar operand type has greater rank than the type of the vector "
-    "element. (%0 and %1)">;
 def err_bad_kernel_param_type : Error<
   "%0 cannot be used as the type of a kernel parameter">;
 def err_record_with_pointers_kernel_param : Error<
index b1a07ffb7206faf1109383fc68b24852c88c23c5..759c82eeaa07717801b952f01c20367e3302fe7c 100644 (file)
@@ -8074,38 +8074,28 @@ QualType Sema::InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
 /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except
 /// for float->int.
 ///
-/// OpenCL V2.0 6.2.6.p2:
-/// An error shall occur if any scalar operand type has greater rank
-/// than the type of the vector element.
-///
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
                                      QualType scalarTy,
                                      QualType vectorEltTy,
-                                     QualType vectorTy,
-                                     unsigned &DiagID) {
+                                     QualType vectorTy) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_Invalid;
   
   if (vectorEltTy->isIntegralType(S.Context)) {
-    if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
-        (scalarTy->isIntegerType() &&
-         S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
-      DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
-      return true;
-    }
     if (!scalarTy->isIntegralType(S.Context))
       return true;
+    if (S.getLangOpts().OpenCL &&
+        S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0)
+      return true;
     scalarCast = CK_IntegralCast;
   } else if (vectorEltTy->isRealFloatingType()) {
     if (scalarTy->isRealFloatingType()) {
       if (S.getLangOpts().OpenCL &&
-          S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) {
-        DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
+          S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0)
         return true;
-      }
       scalarCast = CK_FloatingCast;
     }
     else if (scalarTy->isIntegralType(S.Context))
@@ -8351,12 +8341,10 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
 
   // If there's a vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
-  unsigned DiagID = diag::err_typecheck_vector_not_convertable;
   if (!RHSVecType) {
     if (isa<ExtVectorType>(LHSVecType)) {
       if (!tryVectorConvertAndSplat(*this, &RHS, RHSType,
-                                    LHSVecType->getElementType(), LHSType,
-                                    DiagID))
+                                    LHSVecType->getElementType(), LHSType))
         return LHSType;
     } else {
       if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS))
@@ -8367,7 +8355,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     if (isa<ExtVectorType>(RHSVecType)) {
       if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS),
                                     LHSType, RHSVecType->getElementType(),
-                                    RHSType, DiagID))
+                                    RHSType))
         return RHSType;
     } else {
       if (LHS.get()->getValueKind() == VK_LValue ||
@@ -8443,7 +8431,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
   }
 
   // Otherwise, use the generic diagnostic.
-  Diag(Loc, DiagID)
+  Diag(Loc, diag::err_typecheck_vector_not_convertable)
     << LHSType << RHSType
     << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
diff --git a/test/SemaOpenCL/arithmetic-conversions.cl b/test/SemaOpenCL/arithmetic-conversions.cl
deleted file mode 100644 (file)
index 64c35e8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-
-typedef float float2 __attribute__((ext_vector_type(2)));
-typedef long long2 __attribute__((ext_vector_type(2)));
-typedef int int2 __attribute__((ext_vector_type(2)));
-
-kernel void foo1(float2 in, global float2 *out) { *out = in + 0.5;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('float2' (vector of 2 'float' values) and 'double')}}
-
-kernel void foo2(float2 in, global float2 *out) { *out = 0.5 + in;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('double' and 'float2' (vector of 2 'float' values))}}
-
-kernel void foo3(float2 in, global float2 *out) { *out = 0.5f + in;}
-
-kernel void foo4(long2 in, global long2 *out) { *out = 5 + in;}
-
-kernel void foo5(float2 in, global float2 *out) {
-    float* f;
-    *out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('float *' and 'float2' (vector of 2 'float' values))}}
-}
-
-kernel void foo6(int2 in, global int2 *out) {
-    int* f;
-    *out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('int *' and 'int2' (vector of 2 'int' values))}}
-}
index 851947cd390fba0ca29fe4fcf82d4cea1b542a9c..60f70564d8616e339dcb201abd00d78183ac2b52 100644 (file)
@@ -89,7 +89,7 @@ float2 ntest04(int2 C, int2 X, float2 Y)
 
 float2 ntest05(int2 C, int2 X, float Y)
 {
-  return C ? X : Y; // expected-error {{scalar operand type has greater rank than the type of the vector element. ('int2' (vector of 2 'int' values) and 'float'}}
+  return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float')}}
 }
 
 char2 ntest06(int2 C, char2 X, char2 Y)