[clang] [HLSL] Add deprecation warnings to compatability overloads (PR #159208)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 19 09:46:13 PDT 2025
https://github.com/spall updated https://github.com/llvm/llvm-project/pull/159208
>From 209cabfdf7ed782d39ece1f3447286731f13652b Mon Sep 17 00:00:00 2001
From: Sarah Spall <sarahspall at microsoft.com>
Date: Mon, 8 Sep 2025 16:01:22 -0700
Subject: [PATCH 1/2] add deprecation warnings + tests
---
.../lib/Headers/hlsl/hlsl_compat_overloads.h | 118 +++++++++++++++---
.../binary-compat-overload-warnings.hlsl | 46 +++++++
.../ternary-compat-overload-warnings.hlsl | 44 +++++++
.../unary-compat-overload-warnings.hlsl | 67 ++++++++++
.../vec-scalar-compat-overload-warnings.hlsl | 41 ++++++
5 files changed, 299 insertions(+), 17 deletions(-)
create mode 100644 clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
create mode 100644 clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
create mode 100644 clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
create mode 100644 clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
diff --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
index 4874206d349c0..72a7bed21f3c9 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -12,148 +12,220 @@
namespace hlsl {
// Note: Functions in this file are sorted alphabetically, then grouped by base
-// element type, and the element types are sorted by size, then singed integer,
+// element type, and the element types are sorted by size, then signed integer,
// unsigned integer and floating point. Keeping this ordering consistent will
// help keep this file manageable as it grows.
+#define _DXC_DEPRECATED_64BIT_FN(fn) \
+ [[deprecated("In 202x 64 bit API lowering for " #fn " is deprecated. " \
+ "Explicitly cast parameters to 32 or 16 bit types.")]]
+
+#define _DXC_DEPRECATED_INT_FN(fn) \
+ [[deprecated("In 202x int lowering for " #fn " is deprecated. " \
+ "Explicitly cast parameters to float types.")]]
+
+#define _DXC_DEPRECATED_VEC_SCALAR_FN(fn) \
+ [[deprecated("In 202x mismatched vector/scalar lowering for " #fn " is " \
+ "deprecated. Explicitly cast parameters.")]]
+
#define _DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(fn) \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float fn(double V) { return fn((float)V); } \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float2 fn(double2 V) { return fn((float2)V); } \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float3 fn(double3 V) { return fn((float3)V); } \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float4 fn(double4 V) { return fn((float4)V); }
#define _DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(fn) \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float fn(double V1, double V2) { \
return fn((float)V1, (float)V2); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float2 fn(double2 V1, double2 V2) { \
return fn((float2)V1, (float2)V2); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float3 fn(double3 V1, double3 V2) { \
return fn((float3)V1, (float3)V2); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float4 fn(double4 V1, double4 V2) { \
return fn((float4)V1, (float4)V2); \
}
#define _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(fn) \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float fn(double V1, double V2, double V3) { \
return fn((float)V1, (float)V2, (float)V3); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float2 fn(double2 V1, double2 V2, double2 V3) { \
return fn((float2)V1, (float2)V2, (float2)V3); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float3 fn(double3 V1, double3 V2, double3 V3) { \
return fn((float3)V1, (float3)V2, (float3)V3); \
} \
+ _DXC_DEPRECATED_64BIT_FN(fn) \
constexpr float4 fn(double4 V1, double4 V2, double4 V3) { \
return fn((float4)V1, (float4)V2, (float4)V3); \
}
#define _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(fn) \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int V) { return fn((float)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int2 V) { return fn((float2)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int3 V) { return fn((float3)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int4 V) { return fn((float4)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint V) { return fn((float)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint2 V) { return fn((float2)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint3 V) { return fn((float3)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint4 V) { return fn((float4)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int64_t V) { return fn((float)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int64_t2 V) { return fn((float2)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int64_t3 V) { return fn((float3)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int64_t4 V) { return fn((float4)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint64_t V) { return fn((float)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint64_t2 V) { return fn((float2)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint64_t3 V) { return fn((float3)V); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint64_t4 V) { return fn((float4)V); }
#define _DXC_COMPAT_BINARY_INTEGER_OVERLOADS(fn) \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int V1, int V2) { return fn((float)V1, (float)V2); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int2 V1, int2 V2) { return fn((float2)V1, (float2)V2); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int3 V1, int3 V2) { return fn((float3)V1, (float3)V2); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int4 V1, int4 V2) { return fn((float4)V1, (float4)V2); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint V1, uint V2) { return fn((float)V1, (float)V2); } \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint2 V1, uint2 V2) { \
return fn((float2)V1, (float2)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint3 V1, uint3 V2) { \
return fn((float3)V1, (float3)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint4 V1, uint4 V2) { \
return fn((float4)V1, (float4)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int64_t V1, int64_t V2) { \
return fn((float)V1, (float)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int64_t2 V1, int64_t2 V2) { \
return fn((float2)V1, (float2)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int64_t3 V1, int64_t3 V2) { \
return fn((float3)V1, (float3)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int64_t4 V1, int64_t4 V2) { \
return fn((float4)V1, (float4)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint64_t V1, uint64_t V2) { \
return fn((float)V1, (float)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint64_t2 V1, uint64_t2 V2) { \
return fn((float2)V1, (float2)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint64_t3 V1, uint64_t3 V2) { \
return fn((float3)V1, (float3)V2); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint64_t4 V1, uint64_t4 V2) { \
return fn((float4)V1, (float4)V2); \
}
#define _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(fn) \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int V1, int V2, int V3) { \
return fn((float)V1, (float)V2, (float)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int2 V1, int2 V2, int2 V3) { \
return fn((float2)V1, (float2)V2, (float2)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int3 V1, int3 V2, int3 V3) { \
return fn((float3)V1, (float3)V2, (float3)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int4 V1, int4 V2, int4 V3) { \
return fn((float4)V1, (float4)V2, (float4)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint V1, uint V2, uint V3) { \
return fn((float)V1, (float)V2, (float)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint2 V1, uint2 V2, uint2 V3) { \
return fn((float2)V1, (float2)V2, (float2)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint3 V1, uint3 V2, uint3 V3) { \
return fn((float3)V1, (float3)V2, (float3)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint4 V1, uint4 V2, uint4 V3) { \
return fn((float4)V1, (float4)V2, (float4)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(int64_t V1, int64_t V2, int64_t V3) { \
return fn((float)V1, (float)V2, (float)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(int64_t2 V1, int64_t2 V2, int64_t2 V3) { \
return fn((float2)V1, (float2)V2, (float2)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(int64_t3 V1, int64_t3 V2, int64_t3 V3) { \
return fn((float3)V1, (float3)V2, (float3)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(int64_t4 V1, int64_t4 V2, int64_t4 V3) { \
return fn((float4)V1, (float4)V2, (float4)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float fn(uint64_t V1, uint64_t V2, uint64_t V3) { \
return fn((float)V1, (float)V2, (float)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float2 fn(uint64_t2 V1, uint64_t2 V2, uint64_t2 V3) { \
return fn((float2)V1, (float2)V2, (float2)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float3 fn(uint64_t3 V1, uint64_t3 V2, uint64_t3 V3) { \
return fn((float3)V1, (float3)V2, (float3)V3); \
} \
+ _DXC_DEPRECATED_INT_FN(fn) \
constexpr float4 fn(uint64_t4 V1, uint64_t4 V2, uint64_t4 V3) { \
return fn((float4)V1, (float4)V2, (float4)V3); \
}
@@ -198,20 +270,23 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(ceil)
//===----------------------------------------------------------------------===//
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-clamp(vector<T, N> p0, vector<T, N> p1, T p2) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(clamp)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> clamp(
+ vector<T, N> p0, vector<T, N> p1, T p2) {
return clamp(p0, p1, (vector<T, N>)p2);
}
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-clamp(vector<T, N> p0, T p1, vector<T, N> p2) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(clamp)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> clamp(
+ vector<T, N> p0, T p1, vector<T, N> p2) {
return clamp(p0, (vector<T, N>)p1, p2);
}
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-clamp(vector<T, N> p0, T p1, T p2) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(clamp)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> clamp(
+ vector<T, N> p0, T p1, T p2) {
return clamp(p0, (vector<T, N>)p1, (vector<T, N>)p2);
}
@@ -268,9 +343,13 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(frac)
// isinf builtins overloads
//===----------------------------------------------------------------------===//
+_DXC_DEPRECATED_64BIT_FN(fn)
constexpr bool isinf(double V) { return isinf((float)V); }
+_DXC_DEPRECATED_64BIT_FN(fn)
constexpr bool2 isinf(double2 V) { return isinf((float2)V); }
+_DXC_DEPRECATED_64BIT_FN(fn)
constexpr bool3 isinf(double3 V) { return isinf((float3)V); }
+_DXC_DEPRECATED_64BIT_FN(fn)
constexpr bool4 isinf(double4 V) { return isinf((float4)V); }
//===----------------------------------------------------------------------===//
@@ -278,8 +357,9 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); }
//===----------------------------------------------------------------------===//
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-lerp(vector<T, N> x, vector<T, N> y, T s) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(lerp)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> lerp(
+ vector<T, N> x, vector<T, N> y, T s) {
return lerp(x, y, (vector<T, N>)s);
}
@@ -312,14 +392,16 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(log2)
//===----------------------------------------------------------------------===//
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-max(vector<T, N> p0, T p1) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(max)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> max(
+ vector<T, N> p0, T p1) {
return max(p0, (vector<T, N>)p1);
}
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-max(T p0, vector<T, N> p1) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(max)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> max(
+ T p0, vector<T, N> p1) {
return max((vector<T, N>)p0, p1);
}
@@ -328,14 +410,16 @@ max(T p0, vector<T, N> p1) {
//===----------------------------------------------------------------------===//
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-min(vector<T, N> p0, T p1) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(min)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> min(
+ vector<T, N> p0, T p1) {
return min(p0, (vector<T, N>)p1);
}
template <typename T, uint N>
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>>
-min(T p0, vector<T, N> p1) {
+_DXC_DEPRECATED_VEC_SCALAR_FN(min)
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> min(
+ T p0, vector<T, N> p1) {
return min((vector<T, N>)p0, p1);
}
diff --git a/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
new file mode 100644
index 0000000000000..840fd62feb04e
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
@@ -0,0 +1,46 @@
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=atan2 %s 2>&1 | FileCheck %s -DFUNC=atan2
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=pow %s 2>&1 | FileCheck %s -DFUNC=pow
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=step %s 2>&1 | FileCheck %s -DFUNC=step
+
+// binary double overloads
+float test_binary_double(double p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0);
+}
+
+float2 test_binary_double2(double2 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0);
+}
+
+float3 test_binary_double3(double3 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0);
+}
+
+float4 test_binary_double4(double4 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0);
+}
+
+// binary integer overloads
+// only test scalar ones for brevity
+float test_binary_int(int p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0);
+}
+
+float test_binary_int(uint p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0);
+}
+
+float test_binary_int(int64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0);
+}
+
+float test_binary_int(uint64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0);
+}
diff --git a/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
new file mode 100644
index 0000000000000..13f9ae70424b3
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
@@ -0,0 +1,44 @@
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=lerp %s 2>&1 | FileCheck %s -DFUNC=lerp
+
+// ternary double overloads
+float test_ternary_double(double p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0, p0);
+}
+
+float2 test_ternary_double2(double2 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0, p0);
+}
+
+float3 test_ternary_double3(double3 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0, p0);
+}
+
+float4 test_ternary_double4(double4 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0, p0, p0);
+}
+
+// ternary integer overloads
+// only test scalar ones for brevity
+float test_ternary_int(int p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0, p0);
+}
+
+float test_ternary_int(uint p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0, p0);
+}
+
+float test_ternary_int(int64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0, p0);
+}
+
+float test_ternary_int(uint64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0, p0, p0);
+}
diff --git a/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
new file mode 100644
index 0000000000000..65186c7ea1667
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
@@ -0,0 +1,67 @@
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=acos %s 2>&1 | FileCheck %s -DFUNC=acos
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=asin %s 2>&1 | FileCheck %s -DFUNC=asin
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=atan %s 2>&1 | FileCheck %s -DFUNC=atan
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=ceil %s 2>&1 | FileCheck %s -DFUNC=ceil
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=cos %s 2>&1 | FileCheck %s -DFUNC=cos
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=cosh %s 2>&1 | FileCheck %s -DFUNC=cosh
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=degrees %s 2>&1 | FileCheck %s -DFUNC=degrees
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=exp %s 2>&1 | FileCheck %s -DFUNC=exp
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=exp2 %s 2>&1 | FileCheck %s -DFUNC=exp2
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=floor %s 2>&1 | FileCheck %s -DFUNC=floor
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=frac %s 2>&1 | FileCheck %s -DFUNC=frac
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log %s 2>&1 | FileCheck %s -DFUNC=log
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log10 %s 2>&1 | FileCheck %s -DFUNC=log10
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log2 %s 2>&1 | FileCheck %s -DFUNC=log2
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=normalize %s 2>&1 | FileCheck %s -DFUNC=normalize
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=rsqrt %s 2>&1 | FileCheck %s -DFUNC=rsqrt
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=round %s 2>&1 | FileCheck %s -DFUNC=round
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sin %s 2>&1 | FileCheck %s -DFUNC=sin
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sinh %s 2>&1 | FileCheck %s -DFUNC=sinh
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sqrt %s 2>&1 | FileCheck %s -DFUNC=sqrt
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=tan %s 2>&1 | FileCheck %s -DFUNC=tan
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=tanh %s 2>&1 | FileCheck %s -DFUNC=tanh
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=trunc %s 2>&1 | FileCheck %s -DFUNC=trunc
+// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=radians %s 2>&1 | FileCheck %s -DFUNC=radians
+
+// unary double overloads
+float test_unary_double(double p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0);
+}
+
+float2 test_unary_double2(double2 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0);
+}
+
+float3 test_unary_double3(double3 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0);
+}
+
+float4 test_unary_double4(double4 p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x 64 bit API lowering for [[FUNC]] is deprecated. Explicitly cast parameters to 32 or 16 bit types.
+ return FUNC(p0);
+}
+
+// unary integer overloads
+// only test scalar ones for brevity
+float test_unary_int(int p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0);
+}
+
+float test_unary_int(uint p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0);
+}
+
+float test_unary_int(int64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0);
+}
+
+float test_unary_int(uint64_t p0) {
+ // CHECK: warning: '[[FUNC]]' is deprecated: In 202x int lowering for [[FUNC]] is deprecated. Explicitly cast parameters to float types.
+ return FUNC(p0);
+}
diff --git a/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
new file mode 100644
index 0000000000000..1c5172f537bbe
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
@@ -0,0 +1,41 @@
+// RUN: %clang_dxc -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s
+
+float2 clamp_test1(float2 p0, float2 p1, float p2) {
+ // CHECK: warning: 'clamp<float, 2U>' is deprecated: In 202x mismatched vector/scalar lowering for clamp is deprecated. Explicitly cast parameters.
+ return clamp(p0, p1, p2);
+}
+
+float3 clamp_test2(float3 p0, float p1, float3 p2) {
+ // CHECK: warning: 'clamp<float, 3U>' is deprecated: In 202x mismatched vector/scalar lowering for clamp is deprecated. Explicitly cast parameters.
+ return clamp(p0, p1, p2);
+}
+
+float4 clamp_test3(float4 p0, float p1, float p2) {
+ // CHECK: warning: 'clamp<float, 4U>' is deprecated: In 202x mismatched vector/scalar lowering for clamp is deprecated. Explicitly cast parameters.
+ return clamp(p0, p1, p2);
+}
+
+float3 lerp_test(float3 p0, float3 p1, float p2) {
+ // CHECK: warning: 'lerp<float, 3U>' is deprecated: In 202x mismatched vector/scalar lowering for lerp is deprecated. Explicitly cast parameters.
+ return lerp(p0, p1, p2);
+}
+
+float2 max_test1(float2 p0, float p1) {
+ // CHECK: warning: 'max<float, 2U>' is deprecated: In 202x mismatched vector/scalar lowering for max is deprecated. Explicitly cast parameters.
+ return max(p0, p1);
+}
+
+float3 max_test2(float p0, float3 p1) {
+ // CHECK: warning: 'max<float, 3U>' is deprecated: In 202x mismatched vector/scalar lowering for max is deprecated. Explicitly cast parameters.
+ return max(p0, p1);
+}
+
+float2 min_test1(float2 p0, float p1) {
+ // CHECK: warning: 'min<float, 2U>' is deprecated: In 202x mismatched vector/scalar lowering for min is deprecated. Explicitly cast parameters.
+ return min(p0, p1);
+}
+
+float3 min_test2(float p0, float3 p1) {
+ // CHECK: warning: 'min<float, 3U>' is deprecated: In 202x mismatched vector/scalar lowering for min is deprecated. Explicitly cast parameters.
+ return min(p0, p1);
+}
>From 8d0ed8a51b62f6cc47ad6095678e9e62c3da1bc7 Mon Sep 17 00:00:00 2001
From: Sarah Spall <sarahspall at microsoft.com>
Date: Fri, 19 Sep 2025 09:45:54 -0700
Subject: [PATCH 2/2] use cc1 instead of clang_dxc
---
.../binary-compat-overload-warnings.hlsl | 6 +--
.../ternary-compat-overload-warnings.hlsl | 2 +-
.../unary-compat-overload-warnings.hlsl | 48 +++++++++----------
.../vec-scalar-compat-overload-warnings.hlsl | 2 +-
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
index 840fd62feb04e..27bb683825de8 100644
--- a/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/binary-compat-overload-warnings.hlsl
@@ -1,6 +1,6 @@
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=atan2 %s 2>&1 | FileCheck %s -DFUNC=atan2
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=pow %s 2>&1 | FileCheck %s -DFUNC=pow
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=step %s 2>&1 | FileCheck %s -DFUNC=step
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=atan2 %s 2>&1 | FileCheck %s -DFUNC=atan2
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=pow %s 2>&1 | FileCheck %s -DFUNC=pow
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=step %s 2>&1 | FileCheck %s -DFUNC=step
// binary double overloads
float test_binary_double(double p0) {
diff --git a/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
index 13f9ae70424b3..5572ba5d2c8ec 100644
--- a/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/ternary-compat-overload-warnings.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=lerp %s 2>&1 | FileCheck %s -DFUNC=lerp
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=lerp %s 2>&1 | FileCheck %s -DFUNC=lerp
// ternary double overloads
float test_ternary_double(double p0) {
diff --git a/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
index 65186c7ea1667..165e5d2d0712c 100644
--- a/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/unary-compat-overload-warnings.hlsl
@@ -1,27 +1,27 @@
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=acos %s 2>&1 | FileCheck %s -DFUNC=acos
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=asin %s 2>&1 | FileCheck %s -DFUNC=asin
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=atan %s 2>&1 | FileCheck %s -DFUNC=atan
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=ceil %s 2>&1 | FileCheck %s -DFUNC=ceil
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=cos %s 2>&1 | FileCheck %s -DFUNC=cos
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=cosh %s 2>&1 | FileCheck %s -DFUNC=cosh
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=degrees %s 2>&1 | FileCheck %s -DFUNC=degrees
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=exp %s 2>&1 | FileCheck %s -DFUNC=exp
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=exp2 %s 2>&1 | FileCheck %s -DFUNC=exp2
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=floor %s 2>&1 | FileCheck %s -DFUNC=floor
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=frac %s 2>&1 | FileCheck %s -DFUNC=frac
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log %s 2>&1 | FileCheck %s -DFUNC=log
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log10 %s 2>&1 | FileCheck %s -DFUNC=log10
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=log2 %s 2>&1 | FileCheck %s -DFUNC=log2
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=normalize %s 2>&1 | FileCheck %s -DFUNC=normalize
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=rsqrt %s 2>&1 | FileCheck %s -DFUNC=rsqrt
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=round %s 2>&1 | FileCheck %s -DFUNC=round
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sin %s 2>&1 | FileCheck %s -DFUNC=sin
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sinh %s 2>&1 | FileCheck %s -DFUNC=sinh
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=sqrt %s 2>&1 | FileCheck %s -DFUNC=sqrt
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=tan %s 2>&1 | FileCheck %s -DFUNC=tan
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=tanh %s 2>&1 | FileCheck %s -DFUNC=tanh
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=trunc %s 2>&1 | FileCheck %s -DFUNC=trunc
-// RUN: %clang_dxc -T cs_6_0 -HV 202x -DFUNC=radians %s 2>&1 | FileCheck %s -DFUNC=radians
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=acos %s 2>&1 | FileCheck %s -DFUNC=acos
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=asin %s 2>&1 | FileCheck %s -DFUNC=asin
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=atan %s 2>&1 | FileCheck %s -DFUNC=atan
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=ceil %s 2>&1 | FileCheck %s -DFUNC=ceil
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=cos %s 2>&1 | FileCheck %s -DFUNC=cos
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=cosh %s 2>&1 | FileCheck %s -DFUNC=cosh
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=degrees %s 2>&1 | FileCheck %s -DFUNC=degrees
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=exp %s 2>&1 | FileCheck %s -DFUNC=exp
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=exp2 %s 2>&1 | FileCheck %s -DFUNC=exp2
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=floor %s 2>&1 | FileCheck %s -DFUNC=floor
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=frac %s 2>&1 | FileCheck %s -DFUNC=frac
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=log %s 2>&1 | FileCheck %s -DFUNC=log
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=log10 %s 2>&1 | FileCheck %s -DFUNC=log10
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=log2 %s 2>&1 | FileCheck %s -DFUNC=log2
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=normalize %s 2>&1 | FileCheck %s -DFUNC=normalize
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=rsqrt %s 2>&1 | FileCheck %s -DFUNC=rsqrt
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=round %s 2>&1 | FileCheck %s -DFUNC=round
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=sin %s 2>&1 | FileCheck %s -DFUNC=sin
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=sinh %s 2>&1 | FileCheck %s -DFUNC=sinh
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=sqrt %s 2>&1 | FileCheck %s -DFUNC=sqrt
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=tan %s 2>&1 | FileCheck %s -DFUNC=tan
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=tanh %s 2>&1 | FileCheck %s -DFUNC=tanh
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=trunc %s 2>&1 | FileCheck %s -DFUNC=trunc
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes -DFUNC=radians %s 2>&1 | FileCheck %s -DFUNC=radians
// unary double overloads
float test_unary_double(double p0) {
diff --git a/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl b/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
index 1c5172f537bbe..9e942784041fa 100644
--- a/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/vec-scalar-compat-overload-warnings.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -T cs_6_0 -HV 202x %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -finclude-default-header -triple dxilv1.0-unknown-shadermodel6.0-compute -std=hlsl202x -emit-llvm-only -disable-llvm-passes %s 2>&1 | FileCheck %s
float2 clamp_test1(float2 p0, float2 p1, float p2) {
// CHECK: warning: 'clamp<float, 2U>' is deprecated: In 202x mismatched vector/scalar lowering for clamp is deprecated. Explicitly cast parameters.
More information about the cfe-commits
mailing list