[cfe-commits] r143166 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/altivec.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Thu Oct 27 16:31:58 PDT 2011
Author: rsmith
Date: Thu Oct 27 18:31:58 2011
New Revision: 143166
URL: http://llvm.org/viewvc/llvm-project?rev=143166&view=rev
Log:
Add missing lvalue-to-rvalue conversion to vector splat casts.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/altivec.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=143166&r1=143165&r2=143166&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct 27 18:31:58 2011
@@ -4334,7 +4334,9 @@
// be replicated to all the components of the vector
if (numExprs == 1) {
QualType ElemTy = Ty->getAs<VectorType>()->getElementType();
- ExprResult Literal = Owned(exprs[0]);
+ ExprResult Literal = DefaultLvalueConversion(exprs[0]);
+ if (Literal.isInvalid())
+ return ExprError();
Literal = ImpCastExprToType(Literal.take(), ElemTy,
PrepareScalarCast(Literal, ElemTy));
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.take());
@@ -4355,7 +4357,9 @@
VTy->getVectorKind() == VectorType::GenericVector &&
numExprs == 1) {
QualType ElemTy = Ty->getAs<VectorType>()->getElementType();
- ExprResult Literal = Owned(exprs[0]);
+ ExprResult Literal = DefaultLvalueConversion(exprs[0]);
+ if (Literal.isInvalid())
+ return ExprError();
Literal = ImpCastExprToType(Literal.take(), ElemTy,
PrepareScalarCast(Literal, ElemTy));
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.take());
Modified: cfe/trunk/test/SemaCXX/altivec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/altivec.cpp?rev=143166&r1=143165&r2=143166&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/altivec.cpp (original)
+++ cfe/trunk/test/SemaCXX/altivec.cpp Thu Oct 27 18:31:58 2011
@@ -66,3 +66,13 @@
(++vi)[1]=1;
template_f(vi);
}
+
+namespace LValueToRValueConversions {
+ struct Struct {
+ float f();
+ int n();
+ };
+
+ vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}}
+ vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}}
+}
More information about the cfe-commits
mailing list