@@ -2079,14 +2079,6 @@ static bool CheckFloatingOrIntRepresentation(Sema *S, CallExpr *TheCall) {
2079
2079
checkAllSignedTypes);
2080
2080
}
2081
2081
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
-
2090
2082
static bool CheckUnsignedIntRepresentation (Sema *S, CallExpr *TheCall) {
2091
2083
auto checkAllUnsignedTypes = [](clang::QualType PassedType) -> bool {
2092
2084
return !PassedType->hasUnsignedIntegerRepresentation ();
@@ -2258,8 +2250,21 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
2258
2250
return true ;
2259
2251
if (CheckVectorElementCallArgs (&SemaRef, TheCall))
2260
2252
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 ;
2262
2265
return true ;
2266
+ }
2267
+
2263
2268
ExprResult A = TheCall->getArg (0 );
2264
2269
QualType ArgTyA = A.get ()->getType ();
2265
2270
// return type is the same as the input type
0 commit comments