PR39628 Treat all non-zero values as 'true' in bool compound-assignment
in constant evaluation, not just odd values.
llvm-svn: 346699
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3080056..b0dc7d4 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2074,11 +2074,12 @@
QualType DestType, QualType SrcType,
const APSInt &Value) {
unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
- APSInt Result = Value;
// Figure out if this is a truncate, extend or noop cast.
// If the input is signed, do a sign extend, noop, or truncate.
- Result = Result.extOrTrunc(DestWidth);
+ APSInt Result = Value.extOrTrunc(DestWidth);
Result.setIsUnsigned(DestType->isUnsignedIntegerOrEnumerationType());
+ if (DestType->isBooleanType())
+ Result = Value.getBoolValue();
return Result;
}