Skip to content

Commit 47c90c4

Browse files
committed
add vector size checks to clamp templates
1 parent 69dab19 commit 47c90c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/Headers/hlsl/hlsl_compat_overloads.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ namespace hlsl {
2222
//===----------------------------------------------------------------------===//
2323

2424
template <typename T, typename R, typename U, uint N>
25-
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value, vector<T, N>>
25+
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
2626
clamp(vector<T, N> p0, vector<R, N> p1, U p2) {
2727
return __builtin_hlsl_elementwise_clamp(p0, (vector<T, N>)p1,
2828
(vector<T, N>)p2);
2929
}
3030
template <typename T, typename R, typename U, uint N>
31-
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value, vector<T, N>>
31+
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value && (N > 1 && N <= 4), vector<T, N>>
3232
clamp(vector<T, N> p0, U p1, vector<R, N> p2) {
3333
return __builtin_hlsl_elementwise_clamp(p0, (vector<T, N>)p1,
3434
(vector<T, N>)p2);
3535
}
3636
template <typename T, typename U, typename V, uint N>
3737
constexpr __detail::enable_if_t<__detail::is_arithmetic<U>::Value &&
38-
__detail::is_arithmetic<V>::Value,
38+
__detail::is_arithmetic<V>::Value && (N > 1 && N <= 4),
3939
vector<T, N>>
4040
clamp(vector<T, N> p0, U p1, V p2) {
4141
return __builtin_hlsl_elementwise_clamp(p0, (vector<T, N>)p1,
4242
(vector<T, N>)p2);
4343
}
4444
template <typename T, typename R, typename S, uint N>
45-
constexpr vector<T, N> clamp(vector<T, N> p0, vector<R, N> p1,
45+
constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector<T, N>> clamp(vector<T, N> p0, vector<R, N> p1,
4646
vector<S, N> p2) {
4747
return __builtin_hlsl_elementwise_clamp(p0, (vector<T, N>)p1,
4848
(vector<T, N>)p2);

0 commit comments

Comments
 (0)