summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/AST/Expr.cpp6
-rw-r--r--clang/Sema/SemaExpr.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp
index b704d9654b6..b7dbcc7de60 100644
--- a/clang/AST/Expr.cpp
+++ b/clang/AST/Expr.cpp
@@ -195,13 +195,17 @@ Expr::isLvalueResult Expr::isLvalue() {
// first, check the type (C99 6.3.2.1)
if (isa<FunctionType>(TR.getCanonicalType())) // from isObjectType()
return LV_NotObjectType;
+
if (TR->isIncompleteType() && TR->isVoidType())
return LV_IncompleteVoidType;
-
+
// the type looks fine, now check the expression
switch (getStmtClass()) {
case StringLiteralClass: // C99 6.5.1p4
case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
+ // For vectors, make sure base is an lvalue (i.e. not a function call).
+ if (cast<ArraySubscriptExpr>(this)->getBase()->getType()->isVectorType())
+ return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue();
return LV_Valid;
case DeclRefExprClass: // C99 6.5.1p2
if (isa<VarDecl>(cast<DeclRefExpr>(this)->getDecl()))
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index 036809ca3cc..4f0935a73d6 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -709,8 +709,10 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
rhsType = DefaultFunctionArrayConversion(rhsType);
if (lhsType->isArithmeticType() && rhsType->isArithmeticType()) {
- if (lhsType->isVectorType() || rhsType->isVectorType())
- return lhsType == rhsType ? Compatible : Incompatible;
+ if (lhsType->isVectorType() || rhsType->isVectorType()) {
+ if (lhsType.getCanonicalType() != rhsType.getCanonicalType())
+ return Incompatible;
+ }
return Compatible;
} else if (lhsType->isPointerType()) {
if (rhsType->isIntegerType())
OpenPOWER on IntegriCloud