[clang] [HLSL] For builtins aliases, apply implicit conversions before running custom type checking (PR #195365)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 15:57:08 PDT 2026


================
@@ -8,63 +8,69 @@
 // RUN:   -verify-ignore-unexpected=note
 
 float bad_float(float a, float b, float c) {
+  // Overload resolution selects 'double fma(double, double, double)'; args promoted to double.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'float')}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'double' to 'float'}}
 }
 
 float2 bad_float2(float2 a, float2 b, float2 c) {
+  // Overload resolution selects 'double2 fma(double2, double2, double2)'; args promoted to double2.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'float2' (aka 'vector<float, 2>'))}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'vector<double, 2>' (vector of 2 'double' values) to 'vector<float, 2>' (vector of 2 'float' values)}}
 }
 
 float2x2 bad_float2x2(float2x2 a, float2x2 b, float2x2 c) {
+  // Overload resolution selects 'double2x2 fma(double2x2, double2x2, double2x2)'; args promoted.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'float2x2' (aka 'matrix<float, 2, 2>'))}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'matrix<double, 2, 2>' to 'matrix<float, 2, 2>'}}
 }
 
 half bad_half(half a, half b, half c) {
+  // Overload resolution selects 'double fma(double, double, double)'; args promoted to double.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'half')}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'double' to 'half'}}
 }
 
 half2 bad_half2(half2 a, half2 b, half2 c) {
+  // Overload resolution selects 'double2 fma(double2, double2, double2)'; args promoted.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'half2' (aka 'vector<half, 2>'))}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'vector<double, 2>' (vector of 2 'double' values) to 'vector<half, 2>' (vector of 2 'half' values)}}
 }
 
 half2x2 bad_half2x2(half2x2 a, half2x2 b, half2x2 c) {
+  // Overload resolution selects 'double2x2 fma(double2x2, double2x2, double2x2)'; args promoted.
   return fma(a, b, c);
-  // expected-error at -1 {{1st argument must be a scalar, vector, or matrix of double type (was 'half2x2' (aka 'matrix<half, 2, 2>'))}}
+  // expected-warning at -1 {{implicit conversion loses floating-point precision: 'matrix<double, 2, 2>' to 'matrix<half, 2, 2>'}}
 }
 
 double mixed_bad_second(double a, float b, double c) {
+  // Overload resolution selects 'double fma(double, double, double)'; float promoted to double.
   return fma(a, b, c);
-  // expected-error at -1 {{arguments are of different types ('double' vs 'float')}}
----------------
llvm-beanz wrote:

We should add the -Wdouble-promotion flag to this test and verify the warnings are emitted correctly.

https://github.com/llvm/llvm-project/pull/195365


More information about the cfe-commits mailing list