Skip to content

Commit

Permalink
Fix a few more warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glebm committed Jun 17, 2024
1 parent 5634212 commit 637b51c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/dvlnet/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class base : public abstract_net {
virtual tl::expected<void, PacketError> 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;
Expand Down
5 changes: 0 additions & 5 deletions Source/spelldat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
6 changes: 6 additions & 0 deletions Source/utils/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion Source/utils/static_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <utility>

#include "appfat.h"
#include "utils/attributes.h"

namespace devilution {

Expand Down Expand Up @@ -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]; }
Expand Down

0 comments on commit 637b51c

Please sign in to comment.