@@ -2079,14 +2079,6 @@ static bool CheckFloatingOrIntRepresentation(Sema *S, CallExpr *TheCall) {
20792079 checkAllSignedTypes);
20802080}
20812081
2082- static bool CheckBoolRepresentation (Sema *S, CallExpr *TheCall) {
2083- auto checkAllBoolTypes = [](clang::QualType PassedType) -> bool {
2084- return !PassedType->hasIntegerRepresentation ();
2085- };
2086- return CheckAllArgTypesAreCorrect (S, TheCall, S->Context .BoolTy ,
2087- checkAllBoolTypes);
2088- }
2089-
20902082static bool CheckUnsignedIntRepresentation (Sema *S, CallExpr *TheCall) {
20912083 auto checkAllUnsignedTypes = [](clang::QualType PassedType) -> bool {
20922084 return !PassedType->hasUnsignedIntegerRepresentation ();
@@ -2258,8 +2250,21 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
22582250 return true ;
22592251 if (CheckVectorElementCallArgs (&SemaRef, TheCall))
22602252 return true ;
2261- if (CheckBoolRepresentation (&SemaRef, TheCall))
2253+
2254+ // check that the arguments are bools or, if vectors,
2255+ // vectors of bools
2256+ QualType ArgTy = TheCall->getArg (0 )->getType ();
2257+ if (const auto *VecTy = ArgTy->getAs <VectorType>()) {
2258+ ArgTy = VecTy->getElementType ();
2259+ }
2260+ if (!getASTContext ().hasSameUnqualifiedType (ArgTy,
2261+ getASTContext ().BoolTy )) {
2262+ SemaRef.Diag (TheCall->getBeginLoc (),
2263+ diag::err_typecheck_convert_incompatible)
2264+ << ArgTy << getASTContext ().BoolTy << 1 << 0 << 0 ;
22622265 return true ;
2266+ }
2267+
22632268 ExprResult A = TheCall->getArg (0 );
22642269 QualType ArgTyA = A.get ()->getType ();
22652270 // return type is the same as the input type
0 commit comments