<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 25, 2010, at 4:48 PM, John Thompson wrote:</div><blockquote type="cite"><div>I have the first pass at a fix for bug 6895, which I also reported.  However, because of possible problems in altivec.h that are being looked into, it's not quite ready for prime time.  However, I'm hoping for some preliminary feedback to see if I'm on the right track.</div>

<div> </div>
<div>First, some background on the problem.</div>
<div> </div>
<div>Basically, the following produced an "cannot initialize a vector element of type '(type)'" error:</div>
<div><font size="2"></font> </div>
<div><font size="2">vector </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">char</font></font><font size="2"> v1 = (vector </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">char</font></font><font size="2">)((vector </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2">)(1, 2, 3, 4));</font></div>

<div><font size="2"></font> </div>
<div><font size="2">This was because the outer paren expression was trying to make a vector literal out of the inner, instead of making it a cast.  (See the original AltiVec standard at <a href="http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf">http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf</a>, section 2.5.2, where it actually discusses this case.)</font></div>

<div> </div>
<div>After straining my brain to figure out where the fix should go (I think it should be ActOnCastOfParenListExpr), this patch is what I came up with.</div>
<div> </div>
<div>Because I needed some way to determine if the initializers were arithmetic constants or not, I added a function to Expr, isArithmeticConstantExpr, which calls a static function of the same name, which I hacked up from a copy of the CheckICE function used by the isIntegerConstantExpression function.  (Is this plagerism?).  I'm not sure if it's exactly right, complete, or is overkill, but it seems to work for the few cases I've tried.  Is it reasonable to put it in Expr, or should it just be a static function in the one file I use it in?</div></blockquote><div><br></div><div>Is there a reason why the fix can't be "the operand is of vector type and therefore this is a vector cast and not a vector literal"?  I thought building vectors from subvectors was an OpenCL-ism not supported in AltiVec.</div><div><br></div><div>John.</div></div></body></html>