<div dir="ltr">On Thu, Aug 29, 2013 at 10:13 AM, JinGu Kang <span dir="ltr"><<a href="mailto:jingu@codeplay.com" target="_blank">jingu@codeplay.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi all,<br>
<br>
My colleague 'Alistair' tested a simple code and found a error. The simplified code and error message are as following:<br>
<br>
Source code:<br>
typedef char char16 __attribute__((ext_vector_<u></u>type(16)));<br>
<br>
int main(void) {<br>
  char16 valA;<br>
  char valB;<br>
  char valC;<br>
  char16 destVal = valC ? valA : valB;<br>
}<br>
<br>
Error message:<br>
error: can't convert between vector values of different size ('char16' and 'int')<br>
  char16 destVal = valC ? valA : valB;<br>
                                        ^ ~~~~   ~~~~<br>
<br>
This error message comes from "CheckVectorOperands()" function in "CheckConditionalOperands()" function because "UsualArithmeticConversions(<u></u>LHS, RHS)" function is executed before "CheckVectorOperands()" function and "UsualArithmeticConversions(<u></u>LHS, RHS)" function changes RHS as follows:<br>

GDB output of original RHS:<br>
DeclRefExpr 0xc4b3050 'char' lvalue Var 0xc4b2f50 'valB' 'char'<br>
<br>
GDB output of changed RHS:<br>
ImplicitCastExpr 0xc4b30a8 'int' <IntegralCast><br>
`-ImplicitCastExpr 0xc4b3098 'char' <LValueToRValue><br>
  `-DeclRefExpr 0xc4b3050 'char' lvalue Var 0xc4b2f50 'valB' 'char'<br>
<br>
So, the error message is generated between 'char16' and 'int'. I am wondering whether this error is correct or not. I have checked other checking functions executes "CheckVectorOperands()" function before "UsualArithmeticConversions(<u></u>LHS, RHS)" function such as "CheckSubtractionOperands()", "CheckAdditionOperands()" functions and etc... Could someone let me know about this error? I have attached a simple patch to fix it on the assumption that it is not correct.<br>
<br></blockquote><div><br></div><div>The patch is in the right direction; the call to UsualArithmeticConversions should come after the call to CheckVectorOperands.</div><div><br></div><div>Shouldn't the UsualArithmeticConversions call come after the checkConditionalConvertScalarsToVectors check?  Not completely sure here (the rules aren't really clear, and clang's implementation of the check in question isn't consistent with any interpretation of the OpenCL standard).</div>
<div><br></div><div>If you're going to go the route of updating CondTy, LHSTy, and RHSTy whenever the expressions change, please make sure they stay consistently up-to-date throughout the function.</div><div><br></div>
<div>-Eli</div></div></div></div>