Remove two minor compiler warnings/errors:
Found when building with the Fuchsia toolchain, which
uses a recent clang version:
- The constants '1.0f / 0x7FFFFFFF' and
'1.0f / 0xFFFFFFFF' cannot be computed directly without
losing one bit of accuracy, and the compiler was complaining
about it, so use intermediate double values
to get the correct, final result.
- The MemoryMapped class needs to be declared final to
have a final destructor, otherwise the compiler complains
with:
error: class with destructor marked 'final' cannot be inherited from
[-Werror,-Wfinal-dtor-non-final-class]
Bug: None
Change-Id: I9728df87fd5d12418ef7d73aa651eca02b0e36f9
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/42888
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/Constants.cpp b/src/Pipeline/Constants.cpp
index df4b1b2..230e625c 100644
--- a/src/Pipeline/Constants.cpp
+++ b/src/Pipeline/Constants.cpp
@@ -341,8 +341,12 @@
static const float4 unscaleSByte = { 1.0f / 0x7F, 1.0f / 0x7F, 1.0f / 0x7F, 1.0f / 0x7F };
static const float4 unscaleShort = { 1.0f / 0x7FFF, 1.0f / 0x7FFF, 1.0f / 0x7FFF, 1.0f / 0x7FFF };
static const float4 unscaleUShort = { 1.0f / 0xFFFF, 1.0f / 0xFFFF, 1.0f / 0xFFFF, 1.0f / 0xFFFF };
- static const float4 unscaleInt = { 1.0f / 0x7FFFFFFF, 1.0f / 0x7FFFFFFF, 1.0f / 0x7FFFFFFF, 1.0f / 0x7FFFFFFF };
- static const float4 unscaleUInt = { 1.0f / 0xFFFFFFFF, 1.0f / 0xFFFFFFFF, 1.0f / 0xFFFFFFFF, 1.0f / 0xFFFFFFFF };
+
+ // NOTE: Using "1.0f / 0x7FFFFFF" below results in a compiler error, e.g.:
+ // error: implicit conversion from 'int' to 'float' changes value from 2147483646 to 2147483648
+ static const float4 unscaleInt = { (float)(1.0 / 0x7FFFFFFF), (float)(1.0 / 0x7FFFFFFF), (float)(1.0 / 0x7FFFFFFF), (float)(1.0 / 0x7FFFFFFF) };
+ static const float4 unscaleUInt = { (float)(1.0 / 0xFFFFFFFF), (float)(1.0 / 0xFFFFFFFF), (float)(1.0 / 0xFFFFFFFF), (float)(1.0 / 0xFFFFFFFF) };
+
static const float4 unscaleFixed = { 1.0f / 0x00010000, 1.0f / 0x00010000, 1.0f / 0x00010000, 1.0f / 0x00010000 };
memcpy(&this->unscaleByte, &unscaleByte, sizeof(unscaleByte));
@@ -359,4 +363,4 @@
}
}
-} // namespace sw
\ No newline at end of file
+} // namespace sw
diff --git a/src/Reactor/LLVMJIT.cpp b/src/Reactor/LLVMJIT.cpp
index 9fcffb3..e1b1cb7 100644
--- a/src/Reactor/LLVMJIT.cpp
+++ b/src/Reactor/LLVMJIT.cpp
@@ -271,7 +271,7 @@
{
}
-class MemoryMapper : public llvm::SectionMemoryManager::MemoryMapper
+class MemoryMapper final : public llvm::SectionMemoryManager::MemoryMapper
{
public:
MemoryMapper() {}