From 637b51c10345d31ba1bc82cff9c4fd46e10a63dc Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 16 Jun 2024 20:27:40 +0100 Subject: [PATCH] Fix a few more warnings The pure attribute on `StaticVector#empty` is needed so that it can be used in `DVL_ASSUME` without a warning about side-effects in assume. --- Source/dvlnet/base.h | 2 +- Source/spelldat.cpp | 5 ----- Source/utils/attributes.h | 6 ++++++ Source/utils/static_vector.hpp | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/dvlnet/base.h b/Source/dvlnet/base.h index 10979d0ef23..a33f5972a58 100644 --- a/Source/dvlnet/base.h +++ b/Source/dvlnet/base.h @@ -33,7 +33,7 @@ class base : public abstract_net { virtual tl::expected send(packet &pkt) = 0; virtual void DisconnectNet(plr_t plr); - void setup_gameinfo(buffer_t info); + void setup_gameinfo(buffer_t info) override; void setup_password(std::string pw) override; void clear_password() override; diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index a48c6916060..5e61a5137fa 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -17,11 +17,6 @@ namespace devilution { namespace { -const auto Fire = SpellDataFlags::Fire; -const auto Lightning = SpellDataFlags::Lightning; -const auto Magic = SpellDataFlags::Magic; -const auto Targeted = SpellDataFlags::Targeted; -const auto AllowedInTown = SpellDataFlags::AllowedInTown; void AddNullSpell() { diff --git a/Source/utils/attributes.h b/Source/utils/attributes.h index 7d2beb962a7..2f40a9bcb6e 100644 --- a/Source/utils/attributes.h +++ b/Source/utils/attributes.h @@ -18,6 +18,12 @@ #define DVL_PRINTF_ATTRIBUTE(fmtargnum, firstarg) #endif +#if DVL_HAVE_ATTRIBUTE(pure) +#define DVL_PURE __attribute__((pure)) +#else +#define DVL_PURE +#endif + #if DVL_HAVE_ATTRIBUTE(always_inline) #define DVL_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) diff --git a/Source/utils/static_vector.hpp b/Source/utils/static_vector.hpp index 13a0d0ed6b7..fb0de841a21 100644 --- a/Source/utils/static_vector.hpp +++ b/Source/utils/static_vector.hpp @@ -6,6 +6,7 @@ #include #include "appfat.h" +#include "utils/attributes.h" namespace devilution { @@ -36,7 +37,7 @@ class StaticVector { [[nodiscard]] size_t size() const { return size_; } - [[nodiscard]] bool empty() const { return size_ == 0; } + [[nodiscard]] bool empty() const DVL_PURE { return size_ == 0; } [[nodiscard]] const T &back() const { return (*this)[size_ - 1]; } [[nodiscard]] T &back() { return (*this)[size_ - 1]; }