diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-07-06 06:27:27 +0200 |
---|---|---|
committer | Gunnar Beutner <gunnar@beutner.name> | 2021-07-08 10:11:00 +0200 |
commit | e8e628de57789fea4c7266e71f7443fa70a75233 (patch) | |
tree | 8b2bed1c1a3bb60caf76c8fd9b044ec430e9e214 | |
parent | 98a9a1d7f92d314df337af9745fcb58167e1c4e5 (diff) | |
download | serenity-e8e628de57789fea4c7266e71f7443fa70a75233.zip |
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.
-rw-r--r-- | Userland/Libraries/LibM/math.cpp | 9 | ||||
-rw-r--r-- | Userland/Utilities/crash.cpp | 6 |
2 files changed, 14 insertions, 1 deletions
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 <stdint.h> #include <stdlib.h> +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdouble-promotion" +#endif + template<size_t> 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) { |