================
@@ -15884,6 +15884,58 @@ static bool checkBuiltinVectorMathMixedEnums(Sema &S, 
Expr *LHS, Expr *RHS,
   return false;
 }
 
+/// Check if all arguments have the same type. If the types don't match, emit 
an
+/// error message and return true. Otherwise return false.
+///
+/// For scalars we directly compare their unqualified types. But even if we
+/// compare unqualified vector types, a difference in qualifiers in the element
+/// types can make the vector types be considered not equal. For example,
+/// vector of 4 'const float' values vs vector of 4 'float' values.
+/// So we compare unqualified types of their elements and number of elements.
+/// See GitHub issue #155405.
+static bool checkBuiltinVectorMathArgTypes(Sema &SemaRef, unsigned NumArgs,
+                                           Expr *Args[]) {
+  assert(NumArgs > 0 && "Should have at least one argument.");
+
+  auto EmitError = [&](int I) {
+    SemaRef.Diag(Args[0]->getBeginLoc(),
+                 diag::err_typecheck_call_different_arg_types)
+        << Args[0]->getType() << Args[I]->getType();
+  };
+
+  QualType Ty0 = Args[0]->getType();
+
+  // Compare scalar types.
+  if (!Ty0->isVectorType()) {
+    for (unsigned I = 1; I < NumArgs; ++I)
----------------
tbaederr wrote:

```suggestion
    for (unsigned I = 1; I != NumArgs; ++I)
```

https://github.com/llvm/llvm-project/pull/155620
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to