diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index b51cf56f01ea4c24895abb7ef98a26927017ffe7..450e2789c79050ad5ae7e970dc34ce8a54078bfb 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3750,13 +3750,16 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { // If this is an implicit conversion from float -> float or double, remove it. if (ImplicitCastExpr *Cast = dyn_cast<ImplicitCastExpr>(OrigArg)) { - Expr *CastArg = Cast->getSubExpr(); - if (CastArg->getType()->isSpecificBuiltinType(BuiltinType::Float)) { - assert((Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) || - Cast->getType()->isSpecificBuiltinType(BuiltinType::Float)) && - "promotion from float to either float or double is the only expected cast here"); - Cast->setSubExpr(nullptr); - TheCall->setArg(NumArgs-1, CastArg); + // Only remove standard FloatCasts, leaving other casts inplace + if (Cast->getCastKind() == CK_FloatingCast) { + Expr *CastArg = Cast->getSubExpr(); + if (CastArg->getType()->isSpecificBuiltinType(BuiltinType::Float)) { + assert((Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) || + Cast->getType()->isSpecificBuiltinType(BuiltinType::Float)) && + "promotion from float to either float or double is the only expected cast here"); + Cast->setSubExpr(nullptr); + TheCall->setArg(NumArgs-1, CastArg); + } } } diff --git a/test/SemaOpenCL/extensions.cl b/test/SemaOpenCL/extensions.cl index b03428ad33bbeeeb75356344c8188f7e326890aa..688185ec207cf61e208fa1e419ff935e152f213f 100644 --- a/test/SemaOpenCL/extensions.cl +++ b/test/SemaOpenCL/extensions.cl @@ -35,6 +35,14 @@ void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 exte } #endif +int isnan(float x) { + return __builtin_isnan(x); +} + +int isfinite(float x) { + return __builtin_isfinite(x); +} + #pragma OPENCL EXTENSION cl_khr_fp64 : enable #ifdef NOFP64 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}