diff options
author | Jakub Szewczyk <git@kubasz.xyz> | 2022-03-18 22:10:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 15:10:04 -0700 |
commit | 88c2e4377df7dbe65bc8ef629ea409cd9df6a860 (patch) | |
tree | 0fe699c08ef55ed5902304e55851cdb1796c6881 /src/support | |
parent | 967245fbc75217d257eeba15ede4aeb56e3c0d89 (diff) | |
download | binaryen-88c2e4377df7dbe65bc8ef629ea409cd9df6a860.tar.gz binaryen-88c2e4377df7dbe65bc8ef629ea409cd9df6a860.tar.bz2 binaryen-88c2e4377df7dbe65bc8ef629ea409cd9df6a860.zip |
Fix errors when building in C++20 mode (#4528)
* use [[noreturn]] available since C++11 instead of compiler-specific attributes
* replace deprecated std::is_pod with is_trivial&&is_standard_layout (also available since C++11/14)
* explicitly capture this in [=] lambdas
* extra const functions in FeatureSet, fix implicit cast warning by using the features field directly
* Use CMAKE_CXX_STANDARD to ensure the C++ standard parameter is set on all targets, remove manual compiler flag workaround.
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/utilities.cpp | 5 | ||||
-rw-r--r-- | src/support/utilities.h | 15 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/support/utilities.cpp b/src/support/utilities.cpp index ea426df9c..f051a1871 100644 --- a/src/support/utilities.cpp +++ b/src/support/utilities.cpp @@ -24,9 +24,8 @@ #include "sanitizer/common_interface_defs.h" #endif -void wasm::handle_unreachable(const char* msg, - const char* file, - unsigned line) { +[[noreturn]] void +wasm::handle_unreachable(const char* msg, const char* file, unsigned line) { #ifndef NDEBUG if (msg) { std::cerr << msg << "\n"; diff --git a/src/support/utilities.h b/src/support/utilities.h index 38fe6fd73..57d170269 100644 --- a/src/support/utilities.h +++ b/src/support/utilities.h @@ -36,8 +36,11 @@ template<class Destination, class Source> inline Destination bit_cast(const Source& source) { static_assert(sizeof(Destination) == sizeof(Source), "bit_cast needs to be between types of the same size"); - static_assert(std::is_pod<Destination>::value, "non-POD bit_cast undefined"); - static_assert(std::is_pod<Source>::value, "non-POD bit_cast undefined"); + static_assert(std::is_trivial_v<Destination> && + std::is_standard_layout_v<Destination>, + "non-POD bit_cast undefined"); + static_assert(std::is_trivial_v<Source> && std::is_standard_layout_v<Source>, + "non-POD bit_cast undefined"); Destination destination; std::memcpy(&destination, &source, sizeof(destination)); return destination; @@ -65,7 +68,7 @@ public: std::cerr << arg; return *this; } - WASM_NORETURN ~Fatal() { + [[noreturn]] ~Fatal() { std::cerr << "\n"; // Use _Exit here to avoid calling static destructors. This avoids deadlocks // in (for example) the thread worker pool, where workers hold a lock while @@ -74,9 +77,9 @@ public: } }; -WASM_NORETURN void handle_unreachable(const char* msg = nullptr, - const char* file = nullptr, - unsigned line = 0); +[[noreturn]] void handle_unreachable(const char* msg = nullptr, + const char* file = nullptr, + unsigned line = 0); // If control flow reaches the point of the WASM_UNREACHABLE(), the program is // undefined. |