================
@@ -3148,9 +3148,11 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
case CK_IntegralComplexToBoolean: {
CodeGenFunction::ComplexPairTy V = CGF.EmitComplexExpr(E);
+ // The destination may be an enumeration whose underlying type is bool
+ // (C23 6.7.3.3p16), so convert to bool rather than to DestTy.
// TODO: kill this function off, inline appropriate case here
- return EmitComplexToScalarConversion(V, E->getType(), DestTy,
- CE->getExprLoc());
+ return EmitComplexToScalarConversion(
+ V, E->getType(), CGF.getContext().BoolTy, CE->getExprLoc());
----------------
mohitmishra786 wrote:
Moved it there in af5100f19, and added the same check to EmitScalarConversion.
That also fixes compound assignment, which went through these functions with
the enum as the destination: `e += 2` with e == 0 gave 0, and `e += 0.5` / `e
+= 2.0i` used fptoui to i1. The bool case for ++ now covers these enums as well
(`e++` with e == 1 gave 0, and the atomic form used atomicrmw add). Added tests
for all of these.
https://github.com/llvm/llvm-project/pull/244494
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits