Skip to content

Commit 33d9af3

Browse files
[SYCL][NFC] Fix warnings coming out of SYCL headers. (#3978)
The problem was discovered in /#3777. Fixed by wrapping `x` `_SYCL_SPAN_ASSERT` argument into parentheses. Example of the warning/error: ``` sycl/CL/sycl/sycl_span.hpp:515:82: error: '&&' within '||' [-Werror,-Wlogical-op-parentheses] (static_cast <bool> ((_Count == dynamic_extent || _Count <= size() - _Offset && "Offset + count out of range in span::subspan()"))· ? void (0) : __assert_fail ("(_Count == dynamic_extent || _Count <= size() - _Offset && \"Offset + count out of range in span::subspan( )\")", "/sycl/CL/sycl/sycl_span.hpp", 516, __extension__ __PRETTY_FUNCTION__)); sycl/CL/sycl/sycl_span.hpp:515:82: note: place parentheses around the '&&' expression· to silence this warning ``` Fix one more warning and improve warnings LIT test
1 parent 9a9a018 commit 33d9af3

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

sycl/include/CL/sycl/sycl_span.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ using byte = unsigned char;
146146
#if defined(__SYCL_DEVICE_ONLY__)
147147
#define _SYCL_SPAN_ASSERT(x, m) ((void)0)
148148
#else
149-
#define _SYCL_SPAN_ASSERT(x, m) assert((x && m))
149+
#define _SYCL_SPAN_ASSERT(x, m) assert(((x) && m))
150150
#endif
151151

152152
inline constexpr size_t dynamic_extent = SIZE_MAX;

sycl/include/CL/sycl/types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ __SYCL_GENERATE_CONVERT_IMPL_FOR_ROUNDING_MODE(rtn, Rtn)
454454
typename OpenCLT, typename OpenCLR> \
455455
detail::enable_if_t<is_float_to_int<T, R>::value && \
456456
(std::is_same<OpenCLR, cl_##DestType>::value || \
457-
std::is_same<OpenCLR, signed char>::value && \
458-
std::is_same<DestType, char>::value) && \
457+
(std::is_same<OpenCLR, signed char>::value && \
458+
std::is_same<DestType, char>::value)) && \
459459
RoundingModeCondition<roundingMode>::value, \
460460
R> \
461461
convertImpl(T Value) { \

sycl/test/warnings/warnings.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
1-
// RUN: %clangxx -fsycl --no-system-header-prefix=CL/sycl -fsyntax-only -Wall -Wextra -Wno-ignored-attributes -Wno-deprecated-declarations -Wpessimizing-move -Wunused-variable -Wmismatched-tags -Wunneeded-internal-declaration -Werror -Wno-unknown-cuda-version -Wno-unused-parameter %s -o %t.out
2-
1+
// RUN: %clangxx -fsycl --no-system-header-prefix=CL/sycl -fsyntax-only -Wall -Wextra -Werror -Wno-ignored-attributes -Wno-deprecated-declarations -Wpessimizing-move -Wunused-variable -Wmismatched-tags -Wunneeded-internal-declaration -Wno-unknown-cuda-version -Wno-unused-parameter %s
2+
// RUN: %clangxx -fsycl -E --no-system-header-prefix=CL/sycl %s -o %t.ii
3+
// RUN: %clangxx -fsycl -fsyntax-only -Wall -Wextra -Werror -Wno-ignored-attributes -Wno-deprecated-declarations -Wpessimizing-move -Wunused-variable -Wmismatched-tags -Wunneeded-internal-declaration -Wno-unknown-cuda-version -Wno-unused-parameter %t.ii
34
#include <CL/sycl.hpp>
45

56
using namespace cl::sycl;
67
int main() {
78
vec<long, 4> newVec;
89
queue myQueue;
910
buffer<vec<long, 4>, 1> resultBuf{&newVec, range<1>{1}};
10-
myQueue.submit([&](handler &cgh) {
11+
auto event = myQueue.submit([&](handler &cgh) {
1112
auto writeResult = resultBuf.get_access<access::mode::write>(cgh);
1213
cgh.single_task<class kernel_name>([=]() {
1314
writeResult[0] = (vec<int, 4>{1, 2, 3, 4}).template convert<long>();
1415
});
1516
});
17+
(void)event;
1618
return 0;
1719
}
20+
21+
// explicitly instantiate a few more classes to check if there are some issues
22+
// with them:
23+
24+
namespace sycl {
25+
26+
template class buffer<vec<int, 3>, 2>;
27+
28+
template class accessor<int, 1>;
29+
template class accessor<vec<float, 2>, 2, access_mode::read>;
30+
31+
template class marray<double, 7>;
32+
template class marray<short, 3>;
33+
34+
template class kernel_bundle<bundle_state::input>;
35+
template class kernel_bundle<bundle_state::object>;
36+
template class kernel_bundle<bundle_state::executable>;
37+
38+
template class device_image<bundle_state::input>;
39+
template class device_image<bundle_state::object>;
40+
template class device_image<bundle_state::executable>;
41+
42+
}

0 commit comments

Comments
 (0)