@@ -106,44 +106,34 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
106106 return true ;
107107
108108 // check if the all arguments have floating representation
109- ExprResult A = TheCall->getArg (0 );
110- QualType ArgTyA = A.get ()->getType ();
111- if (!ArgTyA->hasFloatingRepresentation ()) {
112- SemaRef.Diag (A.get ()->getBeginLoc (),
113- diag::err_typecheck_convert_incompatible)
114- << ArgTyA << SemaRef.Context .FloatTy << 1 << 0 << 0 ;
115- return true ;
109+ for (unsigned i = 0 ; i < TheCall->getNumArgs (); ++i) {
110+ ExprResult Arg = TheCall->getArg (i);
111+ QualType ArgTy = Arg.get ()->getType ();
112+ if (!ArgTy->hasFloatingRepresentation ()) {
113+ SemaRef.Diag (Arg.get ()->getBeginLoc (),
114+ diag::err_builtin_invalid_arg_type)
115+ << i + 1 << /* scalar or vector */ 5 << /* no int */ 0 << /* fp */ 1
116+ << ArgTy;
117+ return true ;
118+ }
116119 }
117120
121+ // check if all arguments are of the same type
122+ ExprResult A = TheCall->getArg (0 );
118123 ExprResult B = TheCall->getArg (1 );
119- QualType ArgTyB = B.get ()->getType ();
120- if (!ArgTyB->hasFloatingRepresentation ()) {
121- SemaRef.Diag (A.get ()->getBeginLoc (),
122- diag::err_typecheck_convert_incompatible)
123- << ArgTyB << SemaRef.Context .FloatTy << 1 << 0 << 0 ;
124- return true ;
125- }
126-
127124 ExprResult C = TheCall->getArg (2 );
128- QualType ArgTyC = C.get ()->getType ();
129- if (!ArgTyC->hasFloatingRepresentation ()) {
130- SemaRef.Diag (A.get ()->getBeginLoc (),
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))) {
125+ if (!(SemaRef.getASTContext ().hasSameUnqualifiedType (A.get ()->getType (),
126+ B.get ()->getType ()) &&
127+ SemaRef.getASTContext ().hasSameUnqualifiedType (A.get ()->getType (),
128+ C.get ()->getType ()))) {
139129 SemaRef.Diag (TheCall->getBeginLoc (),
140130 diag::err_vec_builtin_incompatible_vector)
141131 << TheCall->getDirectCallee () << /* useAllTerminology*/ true
142132 << SourceRange (A.get ()->getBeginLoc (), C.get ()->getEndLoc ());
143133 return true ;
144134 }
145135
146- QualType RetTy = ArgTyA ;
136+ QualType RetTy = A. get ()-> getType () ;
147137 TheCall->setType (RetTy);
148138 break ;
149139 }
0 commit comments