Pedantic Visual Studio build (/W4 /WX) (#4214)

* Pedantic Visual Studio build (/W4 /WX)

* Pedantic Visual Studio build (/W4 /WX)

* Pedantic Visual Studio build (/W4 /WX)

* Remove /wd4512 from CMakeLists.txt

* Suppress Visual Studio 4512 warning ('class' : assignment operator could not be generated)
This commit is contained in:
chronoxor
2017-03-10 21:27:30 +03:00
committed by Wouter van Oortmerssen
parent e7e4dc755d
commit f5387387de
4 changed files with 34 additions and 6 deletions

View File

@@ -26,6 +26,11 @@
#include <intrin.h>
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4127) // C4127: conditional expression is constant
#endif
namespace flexbuffers {
class Reference;
@@ -105,7 +110,7 @@ inline Type ToTypedVectorElementType(Type t) {
inline Type ToFixedTypedVectorElementType(Type t, uint8_t *len) {
assert(IsFixedTypedVector(t));
auto fixed_type = t - TYPE_VECTOR_INT2;
*len = fixed_type / 3 + 2; // 3 types each, starting from length 2.
*len = static_cast<uint8_t>(fixed_type / 3 + 2); // 3 types each, starting from length 2.
return static_cast<Type>(fixed_type % 3 + TYPE_INT);
}
@@ -602,7 +607,7 @@ class Reference {
template<typename T> bool Mutate(const uint8_t *dest, T t, size_t byte_width,
BitWidth value_width) {
auto fits = static_cast<size_t>(1U << value_width) <= byte_width;
auto fits = static_cast<size_t>(static_cast<size_t>(1U) << value_width) <= byte_width;
if (fits) {
t = flatbuffers::EndianScalar(t);
memcpy(const_cast<uint8_t *>(dest), &t, byte_width);
@@ -1073,7 +1078,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
auto byte_width = 1U << alignment;
buf_.insert(buf_.end(), flatbuffers::PaddingBytes(buf_.size(), byte_width),
0);
return byte_width;
return static_cast<uint8_t>(byte_width);
}
void WriteBytes(const void *val, size_t size) {
@@ -1177,7 +1182,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
auto offset = offset_loc - u_;
// Does it fit?
auto bit_width = WidthU(offset);
if (static_cast<size_t>(1U << bit_width) == byte_width)
if (static_cast<size_t>(static_cast<size_t>(1U) << bit_width) == byte_width)
return bit_width;
}
assert(false); // Must match one of the sizes above.
@@ -1340,4 +1345,8 @@ class Builder FLATBUFFERS_FINAL_CLASS {
} // namespace flexbuffers
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif // FLATBUFFERS_FLEXBUFFERS_H_