Skip to content

[SYCL] Fix deprecation warning for headers #6808

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 1 commit into from
Sep 19, 2022
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
6 changes: 5 additions & 1 deletion sycl/include/sycl/backend/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@

#include <sycl/detail/defines_elementary.hpp>

__SYCL_WARNING("sycl/backend/cuda.hpp is deprecated and no required anymore")
#if !defined(_MSC_VER) || defined(__clang__)
// MSVC doesn't support #warning and we cannot use other methods to report a
// warning from inside a system header (which SYCL is considered to be).
#warning sycl/backend/cuda.hpp is deprecated and not required anymore
#endif
8 changes: 6 additions & 2 deletions sycl/include/sycl/backend/level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

#include <sycl/detail/defines_elementary.hpp>

__SYCL_WARNING("sycl/backend/level_zero.hpp usage is deprecated, include "
"sycl/ext/oneapi/backend/level_zero.hpp instead")
#if !defined(_MSC_VER) || defined(__clang__)
// MSVC doesn't support #warning and we cannot use other methods to report a
// warning from inside a system header (which SYCL is considered to be).
#warning sycl/backend/level_zero.hpp usage is deprecated, include \
sycl/ext/oneapi/backend/level_zero.hpp instead
#endif

#include <sycl/ext/oneapi/backend/level_zero.hpp>
13 changes: 0 additions & 13 deletions sycl/include/sycl/detail/defines_elementary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,5 @@
#define __SYCL_STRINGIFY(x) #x
#endif // __SYCL_STRINGIFY

// define __SYCL_WARNING convenience macro to report compiler warnings
#if defined(__GNUC__)
#define __SYCL_WARNING(msg) _Pragma(__SYCL_STRINGIFY(GCC warning msg))
#elif defined(_MSC_VER) && !defined(__clang__)
#define __SYCL_QUOTE1(x) #x
#define __SYCL_QUOTE(x) __SYCL_QUOTE1(x)
#define __SYCL_SRC_LOC __FILE__ ":" __SYCL_QUOTE(__LINE__)
#define __SYCL_WARNING(msg) __pragma(message(__SYCL_SRC_LOC " warning: " msg))
#else // clang et. al.
// clang emits "warning:" in the message pragma output
#define __SYCL_WARNING(msg) __pragma(message(msg))
#endif // __GNUC__

static_assert(__cplusplus >= 201703L,
"DPCPP does not support C++ version earlier than C++17.");
9 changes: 6 additions & 3 deletions sycl/include/sycl/ext/intel/online_compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

#include <sycl/detail/defines_elementary.hpp>

__SYCL_WARNING(
"sycl/ext/intel/online_compiler.hpp usage is deprecated, include "
"sycl/ext/intel/experimental/online_compiler.hpp instead")
#if !defined(_MSC_VER) || defined(__clang__)
// MSVC doesn't support #warning and we cannot use other methods to report a
// warning from inside a system header (which SYCL is considered to be).
#warning sycl/ext/intel/online_compiler.hpp usage is deprecated, \
include sycl/ext/intel/experimental/online_compiler.hpp instead
#endif

#include <sycl/ext/intel/experimental/online_compiler.hpp>
11 changes: 11 additions & 0 deletions sycl/test/warnings/deprecated_headers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
#include <sycl/sycl.hpp>

// expected-warning@sycl/backend/cuda.hpp:17 {{sycl/backend/cuda.hpp is deprecated and not required anymore}}
#include <sycl/backend/cuda.hpp>

// expected-warning@sycl/backend/level_zero.hpp:16 {{sycl/backend/level_zero.hpp usage is deprecated, include sycl/ext/oneapi/backend/level_zero.hpp instead}}
#include <sycl/backend/level_zero.hpp>

// expected-warning@sycl/ext/intel/online_compiler.hpp:16 {{sycl/ext/intel/online_compiler.hpp usage is deprecated, include sycl/ext/intel/experimental/online_compiler.hpp instead}}
#include <sycl/ext/intel/online_compiler.hpp>
2 changes: 1 addition & 1 deletion sycl/test/warnings/sycl_2020_deprecations.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clangxx %fsycl-host-only -fsyntax-only -ferror-limit=100 -sycl-std=2020 -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out

#include <CL/sycl.hpp>
#include <sycl/ext/intel/online_compiler.hpp>
#include <sycl/ext/intel/experimental/online_compiler.hpp>

int main() {
cl_context ClCtx;
Expand Down