<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 12/17/2014 10:14 AM, Sahasrabuddhe,
      Sameer wrote:<br>
    </div>
    <blockquote class=" cite" id="mid_54910A47_1050603_amd_com"
      cite="mid:54910A47.1050603@amd.com" type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      > diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp<br>
      > index 04497f3..e37e0c5 100644<br>
      > --- a/lib/Sema/SemaExpr.cpp<br>
      > +++ b/lib/Sema/SemaExpr.cpp<br>
      > @@ -5817,13 +5817,27 @@ QualType
      Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult
      &LHS,<br>
      >    QualType LHSTy = LHS.get()->getType();<br>
      >    QualType RHSTy = RHS.get()->getType();<br>
      >  <br>
      > -  // If the condition is a vector, and both operands are
      scalar,<br>
      > -  // attempt to implicity convert them to the vector type to
      act like the<br>
      > -  // built in select. (OpenCL v1.1 s6.3.i)<br>
      > -  if (getLangOpts().OpenCL &&
      CondTy->isVectorType())<br>
      > -    if (checkConditionalConvertScalarsToVectors(*this, LHS,
      RHS, CondTy))<br>
      > -      return QualType();<br>
      > -  <br>
      > +  if (getLangOpts().OpenCL) {<br>
      > +    if (CondTy->isVectorType()){<br>
      > +      if
(CondTy->getAs<VectorType>()->getElementType()->isFloatingType())<br>
      <br>
      This needs to be checked for the scalar operator too.<br>
      <br>
      > +        Diag(Cond.get()->getLocStart(),
      diag::err_use_of_float_ternary_cond)<br>
      > +            << CondTy;<br>
      > +      if (LHSTy != RHSTy){<br>
      > +        if (LHSTy->isVectorType() &&
      RHSTy->isScalarType())<br>
      > +          RHS = ImpCastExprToType(RHS.get(), LHSTy,
      CK_IntegralCast);<br>
      > +        else if (LHSTy->isScalarType() &&
      RHSTy->isVectorType())<br>
      > +          LHS = ImpCastExprToType(LHS.get(), RHSTy,
      CK_IntegralCast);<br>
      > +      }<br>
      <br>
      This should be moved to the function
      "Sema::UsualArithmeticConversions" in the same file. That function
      implements C99, but needs to be enhanced for Section 6.2.6 from
      OpenCL 1.2 spec, which provides additional conversion rules for
      vector operands. Once we have that, we don't need to worry about
      LHS and RHS; instead, we just use ResTy which is computed just
      before the current point in the code. <br>
    </blockquote>
    <br>
    I made a mistake in reading the code. The vector/scalar conversions
    are already handled by CheckVectorOperands, which is called just
    before calling UsualArithmeticConversions. But the current code is
    immediately returning from there ... instead it should update ResTy
    and continue with further checks.<br>
    <br>
    Sameer.<br>
    <br>
  </body>
</html>