diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/almalloc.h | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f6cf010..515cbddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,7 @@ IF(MSVC) ENDIF() ELSE() SET(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align - -Wpedantic -Wno-zero-length-array + -Wpedantic $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>) IF(ALSOFT_WERROR) diff --git a/common/almalloc.h b/common/almalloc.h index d144ca35..fd8d4be7 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -11,6 +11,23 @@ #include <utility> +#ifdef _MSC_VER +#define DIAGNOSTIC_PUSH _Pragma("warning(push)") +#define GNUDIAGNOSTIC(x) +#define MVSDIAGNOSTIC(x) _Pragma(x) +#define DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif defined(__GNUC__) || defined(__clang__) +#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") +#define GNUDIAGNOSTIC(x) _Pragma(x) +#define MVSDIAGNOSTIC(x) +#define DIAGNOSTIC_POP _Pragma("GCC diagnostic push") +#else +#define DIAGNOSTIC_PUSH +#define GNUDIAGNOSTIC(x) +#define MVSDIAGNOSTIC(x) +#define DIAGNOSTIC_POP +#endif + void *al_malloc(size_t alignment, size_t size); void *al_calloc(size_t alignment, size_t size); void al_free(void *ptr) noexcept; @@ -92,8 +109,14 @@ inline T* assume_aligned(T *ptr) noexcept #endif } +/* At least VS 2015 complains that 'ptr' is unused when the given type's + * destructor is trivial (a no-op). So disable that warning for this call. + */ +DIAGNOSTIC_PUSH +MVSDIAGNOSTIC("warning(disable : 4100)") template<typename T> inline void destroy_at(T *ptr) { ptr->~T(); } +DIAGNOSTIC_POP template<typename T> inline void destroy(T first, const T end) @@ -233,7 +256,11 @@ struct FlexArray { const index_type mSize; +DIAGNOSTIC_PUSH +GNUDIAGNOSTIC("GCC diagnostic ignored \"-Wpedantic\"") +MVSDIAGNOSTIC("warning(disable : 4200)") alignas(alignment) element_type mArray[0]; +DIAGNOSTIC_POP static std::unique_ptr<FlexArray> Create(index_type count) { |