@@ -2482,6 +2482,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
2482
2482
VecTy->getElementType ()->isHalfType ());
2483
2483
return true ;
2484
2484
};
2485
+
2486
+ auto CheckArgTypeIsCorrect = [](
2487
+ Sema *S, Expr *Arg, QualType ExpectedType,
2488
+ llvm::function_ref<bool (clang::QualType PassedType)> Check) -> bool {
2489
+ QualType PassedType = Arg->getType ();
2490
+ if (Check (PassedType)) {
2491
+ if (auto *VecTyA = PassedType->getAs <VectorType>())
2492
+ ExpectedType = S->Context .getVectorType (
2493
+ ExpectedType, VecTyA->getNumElements (), VecTyA->getVectorKind ());
2494
+ S->Diag (Arg->getBeginLoc (), diag::err_typecheck_convert_incompatible)
2495
+ << PassedType << ExpectedType << 1 << 0 << 0 ;
2496
+ return true ;
2497
+ }
2498
+ return false ;
2499
+ };
2500
+
2485
2501
if (CheckArgTypeIsCorrect (&SemaRef, TheCall->getArg (0 ),
2486
2502
SemaRef.getASTContext ().HalfTy ,
2487
2503
checkHalfVectorOfSize2))
@@ -2491,8 +2507,12 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
2491
2507
checkHalfVectorOfSize2))
2492
2508
return true ;
2493
2509
2494
- if (CheckArgTypeMatches (&SemaRef, TheCall->getArg (2 ), SemaRef.getASTContext ().FloatTy ))
2510
+ if (!SemaRef.getASTContext ().hasSameUnqualifiedType (TheCall->getArg (2 )->getType (), SemaRef.getASTContext ().FloatTy )) {
2511
+ SemaRef.Diag (TheCall->getArg (2 )->getBeginLoc (), diag::err_typecheck_convert_incompatible)
2512
+ << TheCall->getArg (2 )->getType () << SemaRef.getASTContext ().FloatTy << 1 << 0 << 0 ;
2495
2513
return true ;
2514
+ }
2515
+
2496
2516
TheCall->setType (SemaRef.getASTContext ().FloatTy );
2497
2517
break ;
2498
2518
}
0 commit comments