[Fixed Point Arithmetic] Fixed Point to Boolean Cast
This patch is a part of https://reviews.llvm.org/D48456 in an attempt to split
the casting logic up into smaller patches. This contains the code for casting
from fixed point types to boolean types.
Differential Revision: https://reviews.llvm.org/D53308
llvm-svn: 345063
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 7e16202..d5d9228 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -533,8 +533,7 @@
case Type::STK_Floating: return CK_FloatingToBoolean;
case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean;
case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean;
- case Type::STK_FixedPoint:
- llvm_unreachable("Unknown cast from FixedPoint to boolean");
+ case Type::STK_FixedPoint: return CK_FixedPointToBoolean;
}
llvm_unreachable("unknown scalar type kind");
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 597f220..2cee761 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5894,10 +5894,7 @@
case Type::STK_FixedPoint:
return CK_FixedPointCast;
case Type::STK_Bool:
- Diag(Src.get()->getExprLoc(),
- diag::err_unimplemented_conversion_with_fixed_point_type)
- << DestTy;
- return CK_IntegralToBoolean;
+ return CK_FixedPointToBoolean;
case Type::STK_Integral:
case Type::STK_Floating:
case Type::STK_IntegralComplex:
@@ -12793,12 +12790,6 @@
if (Context.getLangOpts().CPlusPlus) {
// C++03 [expr.unary.op]p8, C++0x [expr.unary.op]p9:
// operand contextually converted to bool.
- if (resultType->getScalarTypeKind() == Type::STK_FixedPoint) {
- return ExprError(
- Diag(Input.get()->getExprLoc(),
- diag::err_unimplemented_conversion_with_fixed_point_type)
- << resultType);
- }
Input = ImpCastExprToType(Input.get(), Context.BoolTy,
ScalarTypeToBooleanCastKind(resultType));
} else if (Context.getLangOpts().OpenCL &&