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