Skip to content

Commit 3fe546f

Browse files
committed
update sema
1 parent 43f17ed commit 3fe546f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2482,6 +2482,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
24822482
VecTy->getElementType()->isHalfType());
24832483
return true;
24842484
};
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+
24852501
if(CheckArgTypeIsCorrect(&SemaRef, TheCall->getArg(0),
24862502
SemaRef.getASTContext().HalfTy,
24872503
checkHalfVectorOfSize2))
@@ -2491,8 +2507,12 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
24912507
checkHalfVectorOfSize2))
24922508
return true;
24932509

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;
24952513
return true;
2514+
}
2515+
24962516
TheCall->setType(SemaRef.getASTContext().FloatTy);
24972517
break;
24982518
}

0 commit comments

Comments
 (0)