]> granicus.if.org Git - clang/commitdiff
the call to UsualArithmeticConversions should come after the call to CheckVectorOpera...
authorJin-Gu Kang <jaykang10@imrc.kist.re.kr>
Mon, 2 Sep 2013 20:32:37 +0000 (20:32 +0000)
committerJin-Gu Kang <jaykang10@imrc.kist.re.kr>
Mon, 2 Sep 2013 20:32:37 +0000 (20:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189773 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/ext-vector.c

index e7061a682fd317c28a76bbf1fbe05cd9f0d3b620..8453a4732f4fa0a64e482764a90b6c1e2f2458d1 100644 (file)
@@ -5444,9 +5444,18 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   VK = VK_RValue;
   OK = OK_Ordinary;
 
+  // First, check the condition.
   Cond = UsualUnaryConversions(Cond.take());
   if (Cond.isInvalid())
     return QualType();
+  if (checkCondition(*this, Cond.get()))
+    return QualType();
+
+  // Now check the two expressions.
+  if (LHS.get()->getType()->isVectorType() ||
+      RHS.get()->getType()->isVectorType())
+    return CheckVectorOperands(LHS, RHS, QuestionLoc, /*isCompAssign*/false);
+
   UsualArithmeticConversions(LHS, RHS);
   if (LHS.isInvalid() || RHS.isInvalid())
     return QualType();
@@ -5455,14 +5464,6 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   QualType LHSTy = LHS.get()->getType();
   QualType RHSTy = RHS.get()->getType();
 
-  // first, check the condition.
-  if (checkCondition(*this, Cond.get()))
-    return QualType();
-
-  // Now check the two expressions.
-  if (LHSTy->isVectorType() || RHSTy->isVectorType())
-    return CheckVectorOperands(LHS, RHS, QuestionLoc, /*isCompAssign*/false);
-
   // If the condition is a vector, and both operands are scalar,
   // attempt to implicity convert them to the vector type to act like the
   // built in select. (OpenCL v1.1 s6.3.i)
index 6fcefbfd358185712392725a9e0a1ee7dc42bc41..0b78e97fbb3660268497d3ff340174bb6291346b 100644 (file)
@@ -291,3 +291,13 @@ int4 test15(uint4 V0) {
 void test16(float2 a, float2 b) {
   float2 t0 = (a + b) / 2;
 } 
+
+typedef char char16 __attribute__((ext_vector_type(16)));
+
+// CHECK: @test17
+void test17(void) {
+  char16 valA;
+  char valB;
+  char valC;
+  char16 destVal = valC ? valA : valB;
+}