Skip to content

[SYCL][NFC] Eliminate struct/class definition/declaration and static/static-inlined function warnings. #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(SYCL_ENABLE_WERROR "Treat all warnings as errors in SYCL project" OFF)

# enable all warnings by default
if (MSVC)
set(CMAKE_CXX_FLAGS "/W4 ${CMAKE_CXX_FLAGS}")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated-declarations")
endif()

if(SYCL_ENABLE_WERROR)
if(MSVC)
set(CMAKE_CXX_FLAGS "/W4 /WX ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}")
add_definitions(
-wd4996 # Suppress 'function': was declared deprecated'
)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/__spirv/spirv_vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" const __attribute__((opencl_constant)) size_t_vec __spirv_BuiltInWork
extern "C" const __attribute__((opencl_constant)) size_t_vec __spirv_BuiltInGlobalOffset;

#define DEFINE_INT_ID_TO_XYZ_CONVERTER(POSTFIX) \
template <int ID> static size_t get##POSTFIX(); \
template <int ID> static inline size_t get##POSTFIX(); \
template <> size_t get##POSTFIX<0>() { return __spirv_BuiltIn##POSTFIX.x; } \
template <> size_t get##POSTFIX<1>() { return __spirv_BuiltIn##POSTFIX.y; } \
template <> size_t get##POSTFIX<2>() { return __spirv_BuiltIn##POSTFIX.z; }
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ using common_rel_ret_t =
template <int N> struct Boolean;

// Try to get vector element count or 1 otherwise
template <typename T, typename Enable = void> class TryToGetNumElements;
template <typename T, typename Enable = void> struct TryToGetNumElements;

template <typename T>
struct TryToGetNumElements<
Expand Down Expand Up @@ -558,7 +558,7 @@ template <typename T> static constexpr T quiet_NaN() {
}

// is_same_vector_size
template <int FirstSize, typename... Args> struct is_same_vector_size_impl;
template <int FirstSize, typename... Args> class is_same_vector_size_impl;

template <int FirstSize, typename T, typename... Args>
class is_same_vector_size_impl<FirstSize, T, Args...> {
Expand All @@ -573,7 +573,7 @@ class is_same_vector_size_impl<FirstSize, T, Args...> {
};

template <int FirstSize>
struct is_same_vector_size_impl<FirstSize> : std::true_type {};
class is_same_vector_size_impl<FirstSize> : public std::true_type {};

template <typename T, typename... Args> class is_same_vector_size {
using CurrentT = remove_pointer_t<T>;
Expand Down
21 changes: 21 additions & 0 deletions sycl/test/warnings/warnings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %clangxx -Wall -Wpessimizing-move -Wunused-variable -Wmismatched-tags -Wunneeded-internal-declaration -Werror -fsycl %s -o %t.out

#include <CL/sycl.hpp>

using namespace cl::sycl;

int main(void) {
// add a very simple kernel to see if compilation succeeds with -Werror
int data1[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

buffer<int, 1> B(data1, range<1>(10), {property::buffer::use_host_ptr()});
queue Q;
Q.submit([&](handler &CGH) {
auto Accessor = B.get_access<access::mode::read_write>(CGH);
CGH.parallel_for<class TheSimpleKernel>(range<1>{10}, [=](id<1> Item) {
Accessor[Item] = 0;
});
});

return 0;
}