[cfe-commits] [REVIEW] - Altivec vector literal casting problem - need feedback - AST/Sema

John McCall rjmccall at apple.com
Mon Jun 28 13:27:24 PDT 2010


On Jun 28, 2010, at 12:05 PM, John Thompson wrote:

> > 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"?
>  
> In the following:
>  
> Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
>                                SourceLocation RParenLoc, ExprArg Op,
>                                TypeSourceInfo *TInfo) {
>   ParenListExpr *PE = (ParenListExpr *)Op.get();
>   QualType Ty = TInfo->getType();
>   bool isAltiVecLiteral = false;
>   // Check for an altivec literal,
>   if (getLangOptions().AltiVec && Ty->isVectorType()) {
>     if (PE->getNumExprs() == 0) {
>       Diag(PE->getExprLoc(), diag::err_altivec_empty_initializer);
>       return ExprError();
>     }
>     Type *peType = PE->getType().getTypePtr();
>     if (peType) {
>       if (peType->isVectorType())
>         isAltiVecLiteral = true;
>     }
>   }
>   // If this is an altivec initializer, '(' type ')' '(' init, ..., init ')'
>   // then handle it as such.
>   if (isAltiVecLiteral) {
> ...
>  
> The peType is null, which I assume means the ParenListExpr type has not been set.
>  
> Should it be set at this point, or is this the wrong place to be checking?

The ParenListExpr is really just a temporary expression node that we don't
calculate a type for.  You should instead check the types of its sub expressions.

John.



More information about the cfe-commits mailing list