diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp index b704d9654b61..b7dbcc7de60a 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(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(this)->getBase()->getType()->isVectorType()) + return cast(this)->getBase()->isLvalue(); return LV_Valid; case DeclRefExprClass: // C99 6.5.1p2 if (isa(cast(this)->getDecl())) diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 036809ca3cc2..4f0935a73d61 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())