================
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fnative-half-type 
-finclude-default-header -Wconversion -verify %s
+
+// This test verifies that the implicit conversion warning for floating-point
+// precision loss works correctly for matrix types. The IsSameFloatAfterCast
+// function is used to suppress warnings for constant values that are precisely
+// representable in the target type.
+
+void TakesHalf2x2(half2x2 H);
+void TakesFloat2x2(float2x2 F);
+
+// Test 1: Non-constant matrix values should warn when precision is lost
+
+void TestNonConstantPrecisionLoss(double2x2 D, float2x2 F) {
+  // Passing double matrix to float parameter - should warn
+  TakesFloat2x2(D);
+  // expected-warning@-1{{implicit conversion loses floating-point precision: 
'double2x2' (aka 'matrix<double, 2, 2>') to 'float2x2' (aka 'matrix<float, 2, 
2>')}}
+
+  // Passing float matrix to half parameter - should warn
+  TakesHalf2x2(F);
+  // expected-warning@-1{{implicit conversion loses floating-point precision: 
'float2x2' (aka 'matrix<float, 2, 2>') to 'half2x2' (aka 'matrix<half, 2, 2>')}}
+
+  // Passing double matrix to half parameter - should warn
+  TakesHalf2x2(D);
+  // expected-warning@-1{{implicit conversion loses floating-point precision: 
'double2x2' (aka 'matrix<double, 2, 2>') to 'half2x2' (aka 'matrix<half, 2, 
2>')}}
+}
+
+// Test 2: Constant matrix values that ARE precisely representable should NOT 
warn
----------------
alsepkow wrote:

nit: seems weird to capitalize 'ARE'

https://github.com/llvm/llvm-project/pull/179568
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to