@@ -105,33 +105,41 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
105105 if (SemaRef.checkArgCount (TheCall, 3 ))
106106 return true ;
107107
108+ // check if the all arguments have floating representation
108109 ExprResult A = TheCall->getArg (0 );
109110 QualType ArgTyA = A.get ()->getType ();
110- auto *VTyA = ArgTyA->getAs <VectorType>();
111- if (!(ArgTyA->isScalarType () || VTyA)) {
111+ if (!ArgTyA->hasFloatingRepresentation ()) {
112112 SemaRef.Diag (A.get ()->getBeginLoc (),
113- diag::err_typecheck_expect_any_scalar_or_vector )
114- << ArgTyA << 1 ;
113+ diag::err_typecheck_convert_incompatible )
114+ << ArgTyA << SemaRef. Context . FloatTy << 1 << 0 << 0 ;
115115 return true ;
116116 }
117117
118118 ExprResult B = TheCall->getArg (1 );
119119 QualType ArgTyB = B.get ()->getType ();
120- auto *VTyB = ArgTyB->getAs <VectorType>();
121- if (!(ArgTyB->isScalarType () || VTyB)) {
120+ if (!ArgTyB->hasFloatingRepresentation ()) {
122121 SemaRef.Diag (A.get ()->getBeginLoc (),
123- diag::err_typecheck_expect_any_scalar_or_vector )
124- << ArgTyB << 1 ;
122+ diag::err_typecheck_convert_incompatible )
123+ << ArgTyB << SemaRef. Context . FloatTy << 1 << 0 << 0 ;
125124 return true ;
126125 }
127126
128127 ExprResult C = TheCall->getArg (2 );
129128 QualType ArgTyC = C.get ()->getType ();
130- auto *VTyC = ArgTyC->getAs <VectorType>();
131- if (!(ArgTyC->isScalarType () || VTyC)) {
129+ if (!ArgTyC->hasFloatingRepresentation ()) {
132130 SemaRef.Diag (A.get ()->getBeginLoc (),
133- diag::err_typecheck_expect_any_scalar_or_vector)
134- << ArgTyC << 1 ;
131+ diag::err_typecheck_convert_incompatible)
132+ << ArgTyC << SemaRef.Context .FloatTy << 1 << 0 << 0 ;
133+ return true ;
134+ }
135+
136+ // check if all arguments are of the same type
137+ if (!(SemaRef.getASTContext ().hasSameUnqualifiedType (ArgTyA, ArgTyB) &&
138+ SemaRef.getASTContext ().hasSameUnqualifiedType (ArgTyA, ArgTyC))) {
139+ SemaRef.Diag (TheCall->getBeginLoc (),
140+ diag::err_vec_builtin_incompatible_vector)
141+ << TheCall->getDirectCallee () << /* useAllTerminology*/ true
142+ << SourceRange (A.get ()->getBeginLoc (), C.get ()->getEndLoc ());
135143 return true ;
136144 }
137145
0 commit comments