Skip to content

Commit 43e713c

Browse files
authored
[SYCL] Emit an error on attempt to compile in less than C++17 mode (#6678)
1 parent 26b7762 commit 43e713c

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

sycl/doc/PreprocessorMacros.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ This file describes macros that have effect on SYCL compiler and run-time.
3434
Disables all deprecation warnings in SYCL runtime headers, including SYCL
3535
1.2.1 deprecations.
3636

37-
- **SYCL_DISABLE_CPP_VERSION_CHECK_WARNING**
38-
39-
Disables a message which warns about unsupported C++ version.
40-
4137
- **SYCL_FALLBACK_ASSERT**
4238

4339
Defining as non-zero enables the fallback assert feature even on devices

sycl/include/sycl/detail/defines_elementary.hpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,5 @@
105105
#define __SYCL_WARNING(msg) __pragma(message(msg))
106106
#endif // __GNUC__
107107

108-
#if !defined(SYCL_DISABLE_CPP_VERSION_CHECK_WARNING) && __cplusplus < 201703L
109-
110-
#if defined(_MSC_VER) && !defined(__clang__)
111-
__SYCL_WARNING("DPCPP does not support C++ version earlier than C++17. Some "
112-
"features might not be available.")
113-
#else
114-
// This is the only way to emit a warning from system headers using clang, it
115-
// cannot be wrapped by a macro(__pragma warning doesn't work in system
116-
// headers). The solution is borrowed from libcxx.
117-
#warning: DPCPP does not support C++ version earlier than C++17. Some features might not be available.
118-
#endif
119-
120-
#endif
108+
static_assert(__cplusplus >= 201703L,
109+
"DPCPP does not support C++ version earlier than C++17.");

sycl/test/basic_tests/stdcpp_compat.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify=expected,cxx14 %s -c -o %t.out
2-
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out -DSYCL_DISABLE_CPP_VERSION_CHECK_WARNING=1
32
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify=cxx14,warning_extension,expected %s -c -o %t.out
43
// RUN: %clangxx -std=c++17 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out
54
// RUN: %clangxx -std=c++20 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out
@@ -10,13 +9,15 @@
109

1110
#include <sycl/sycl.hpp>
1211

13-
// cxx14-warning@* {{DPCPP does not support C++ version earlier than C++17. Some features might not be available.}}
12+
// clang-format off
13+
// cxx14-error@* {{static assertion failed due to requirement '201402L >= 201703L'}}
1414
//
1515
// The next warning is not emitted in device compilation for some reason
1616
// warning_extension-warning@* 0-1 {{#warning is a C++2b extension}}
1717
//
1818
// The next warning is emitted for windows only
1919
// expected-warning@* 0-1 {{Alignment of class vec is not in accordance with SYCL specification requirements, a limitation of the MSVC compiler(Error C2719).Requested alignment applied, limited at 64.}}
20+
// clang-format on
2021

2122
class KernelName1;
2223

0 commit comments

Comments
 (0)