From e8e628de57789fea4c7266e71f7443fa70a75233 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Tue, 6 Jul 2021 06:27:27 +0200 Subject: Everywhere: Add Clang pragmas We use these to prevent UB from being optimized away in `/bin/crash` and to make the compiler not warn about the many implicit floating point type promotions in LibM. --- Userland/Libraries/LibM/math.cpp | 9 +++++++++ Userland/Utilities/crash.cpp | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 6599f9d9ed..121aa10d06 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -14,6 +14,11 @@ #include #include +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdouble-promotion" +#endif + template constexpr double e_to_power(); template<> @@ -1461,3 +1466,7 @@ float nearbyintf(float value) NOEXCEPT return internal_to_integer(value, RoundingMode { fegetround() }); } } + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/Userland/Utilities/crash.cpp b/Userland/Utilities/crash.cpp index e6c9b13d9d..7781517f2d 100644 --- a/Userland/Utilities/crash.cpp +++ b/Userland/Utilities/crash.cpp @@ -21,7 +21,11 @@ using Test::Crash; -#pragma GCC optimize("O0") +#ifdef __clang__ +# pragma clang optimize off +#else +# pragma GCC optimize("O0") +#endif int main(int argc, char** argv) { -- cgit v1.2.3