================
@@ -687,6 +687,48 @@ void Sema::diagnoseZeroToNullptrConversion(CastKind Kind,
const Expr *E) {
<< FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
}
+void Sema::DiagnoseAssignmentBoolContext(Expr *E, QualType Ty) {
+ // Use copy to not alter original expression.
+ Expr *ECopy = E;
+
+ if (Ty->isBooleanType()) {
+ // `bool(x=0)` and if (x=0){} emit:
+ // - ImplicitCastExpr bool IntegralToBoolean
+ // -- ImplicitCastExpr int LValueToRValue
+ // --- Assignment ...
+ // But should still emit this warning (at least gcc does), even if
bool-cast
----------------
PhilippRados wrote:
> Not sure what the question is here, can you clarify?
Basically just asking if `ImplicitCastExpr` is the only valid expression that
can be in between the outer cast and the assignment expression or if there is
another implicit expression that would need to be matched here.
https://github.com/llvm/llvm-project/pull/115234
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits