diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-27 23:31:58 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-27 23:31:58 +0000 |
commit | 61ffd09797d661ae4ae18674d144a27be2d2f5f3 (patch) | |
tree | ee85041d7b52b5d10fa7224299ebe530575ac00a | |
parent | e3271d401e0d47d43cbf0096fbe66356b91931e1 (diff) |
Add missing lvalue-to-rvalue conversion to vector splat casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143166 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/altivec.cpp | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 885b9664d6..880199bc7a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4334,7 +4334,9 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc, // 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 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc, 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()); diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp index 504eb1b336..39421b7c40 100644 --- a/test/SemaCXX/altivec.cpp +++ b/test/SemaCXX/altivec.cpp @@ -66,3 +66,13 @@ void test2() (++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}} +} |