File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#pragma once
10
10
11
+ // Throw warning when including sycl.hpp without using -fsycl flag.
12
+ // Warning can be disabled by defining SYCL_DISABLE_FSYCL_SYCLHPP_WARNING macro.
13
+ #define STRINGIFY (x ) #x
14
+ #define TOSTRING (x ) STRINGIFY(x)
15
+
16
+ #ifdef _MSC_VER
17
+ #define WARNING (msg ) __pragma(message(__FILE__ " (" TOSTRING(__LINE__) " ): warning: " msg))
18
+ #elif defined(__GNUC__) || defined(__clang__)
19
+ #define WARNING (msg ) _Pragma (TOSTRING(GCC warning msg))
20
+ #else
21
+ #define WARNING (msg ) // Unsupported compiler
22
+ #endif
23
+
24
+ #if !defined(SYCL_LANGUAGE_VERSION) && !defined(SYCL_DISABLE_FSYCL_SYCLHPP_WARNING)
25
+ WARNING (" You are including <sycl/sycl.hpp> without -fsycl flag, \
26
+ which is errorenous for device code compilation. This warning \
27
+ can be disabled by setting SYCL_DISABLE_FSYCL_SYCLHPP_WARNING macro." )
28
+ #endif
29
+ #undef WARNING
30
+ #undef TOSTRING
31
+ #undef STRINGIFY
32
+
11
33
#include < sycl/detail/core.hpp>
12
34
13
35
#include < sycl/accessor_image.hpp>
Original file line number Diff line number Diff line change
1
+ // Test to verify that a warning is thrown when the -fsycl flag is not used and
2
+ // <sycl/sycl.hpp> file is included.
3
+ // RUN: %clangxx -I %sycl_include -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
4
+ // RUN: %clangxx -I %sycl_include -fsyntax-only -DSYCL_DISABLE_FSYCL_SYCLHPP_WARNING %s 2>&1 | FileCheck %s --implicit-check-not=CHECK-WARNING
5
+
6
+ // CHECK-WARNING: You are including <sycl/sycl.hpp> without -fsycl flag, which is errorenous for device code compilation.
7
+ #include < sycl/sycl.hpp>
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ if (WIN32 AND "${build_type_lower}" MATCHES "debug")
9
9
endif ()
10
10
11
11
# Disable aspect::image & deprecation warnings.
12
- target_compile_definitions (sycl-ls PRIVATE SYCL_DISABLE_IMAGE_ASPECT_WARNING SYCL2020_DISABLE_DEPRECATION_WARNINGS )
12
+ target_compile_definitions (sycl-ls PRIVATE SYCL_DISABLE_IMAGE_ASPECT_WARNING SYCL2020_DISABLE_DEPRECATION_WARNINGS SYCL_DISABLE_FSYCL_SYCLHPP_WARNING )
13
13
14
14
target_link_libraries (sycl-ls
15
15
PRIVATE
You can’t perform that action at this time.
0 commit comments