diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/Sema.cpp | 14 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 15 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 9b788a7058..7d28026402 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -240,6 +240,20 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, CastKind Kind, ExprValueKind VK, const CXXCastPath *BasePath, CheckedConversionKind CCK) { +#ifndef NDEBUG + if (VK == VK_RValue && !E->isRValue()) { + switch (Kind) { + default: + assert(0 && "can't implicitly cast lvalue to rvalue with this cast kind"); + case CK_LValueToRValue: + case CK_ArrayToPointerDecay: + case CK_FunctionToPointerDecay: + case CK_ToVoid: + break; + } + } +#endif + QualType ExprTy = Context.getCanonicalType(E->getType()); QualType TypeTy = Context.getCanonicalType(Ty); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a733b81361..1e890eef1e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5722,6 +5722,15 @@ QualType Sema::InvalidOperands(SourceLocation Loc, ExprResult &LHS, QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign) { + if (!IsCompAssign) { + LHS = DefaultFunctionArrayLvalueConversion(LHS.take()); + if (LHS.isInvalid()) + return QualType(); + } + RHS = DefaultFunctionArrayLvalueConversion(RHS.take()); + if (RHS.isInvalid()) + return QualType(); + // For conversion purposes, we ignore any qualifiers. // For example, "const float" and "float" are equivalent. QualType LHSType = @@ -6819,8 +6828,10 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, // x == x, x != x, x < x, etc. These always evaluate to a constant, and // often indicate logic errors in the program. if (!LHSType->hasFloatingRepresentation()) { - if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(LHS.get()->IgnoreParens())) - if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RHS.get()->IgnoreParens())) + if (DeclRefExpr* DRL + = dyn_cast<DeclRefExpr>(LHS.get()->IgnoreParenImpCasts())) + if (DeclRefExpr* DRR + = dyn_cast<DeclRefExpr>(RHS.get()->IgnoreParenImpCasts())) if (DRL->getDecl() == DRR->getDecl()) DiagRuntimeBehavior(Loc, 0, PDiag(diag::warn_comparison_always) |