aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp8
-rw-r--r--test/SemaCXX/altivec.cpp10
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}}
+}