incertia updated this revision to Diff 141477. incertia added a comment. Pulled the check outside of the case statement.
https://reviews.llvm.org/D45401 Files: lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -3839,6 +3839,11 @@ FromType = From->getType(); } + // implicit boolean conversions should have their assignments checked + if (SCS.Second == ICK_Boolean_Conversion || FromType == Context.BoolTy) { + DiagnoseAssignmentAsCondition(From->IgnoreImpCasts()); + } + // If we're converting to an atomic type, first convert to the corresponding // non-atomic type. QualType ToAtomicType; Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -15409,7 +15409,10 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr) { - DiagnoseAssignmentAsCondition(E); + // an assignment always produces an lvalue, and we now check this inside + // PerformImplicitConversion, as conditions will always be implicitly + // converted to an rvalue + // DiagnoseAssignmentAsCondition(E); if (ParenExpr *parenE = dyn_cast<ParenExpr>(E)) DiagnoseEqualityWithExtraParens(parenE);
Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -3839,6 +3839,11 @@ FromType = From->getType(); } + // implicit boolean conversions should have their assignments checked + if (SCS.Second == ICK_Boolean_Conversion || FromType == Context.BoolTy) { + DiagnoseAssignmentAsCondition(From->IgnoreImpCasts()); + } + // If we're converting to an atomic type, first convert to the corresponding // non-atomic type. QualType ToAtomicType; Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -15409,7 +15409,10 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr) { - DiagnoseAssignmentAsCondition(E); + // an assignment always produces an lvalue, and we now check this inside + // PerformImplicitConversion, as conditions will always be implicitly + // converted to an rvalue + // DiagnoseAssignmentAsCondition(E); if (ParenExpr *parenE = dyn_cast<ParenExpr>(E)) DiagnoseEqualityWithExtraParens(parenE);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits