build: fix warnings from -Wparentheses

This commit is contained in:
Danny Robson 2018-03-27 20:16:32 +11:00
parent 5642ff43b8
commit 4f10505d09
5 changed files with 16 additions and 8 deletions

View File

@ -39,7 +39,7 @@ namespace util {
constexpr T constexpr T
rotatel [[gnu::pure]] (const T value, std::size_t magnitude) rotatel [[gnu::pure]] (const T value, std::size_t magnitude)
{ {
return (value << magnitude) | (value >> sizeof (value) * 8 - magnitude); return (value << magnitude) | (value >> (sizeof (value) * 8 - magnitude));
} }
@ -47,7 +47,7 @@ namespace util {
constexpr T constexpr T
rotater [[gnu::pure]] (const T value, std::size_t magnitude) rotater [[gnu::pure]] (const T value, std::size_t magnitude)
{ {
return (value >> magnitude) | (value << sizeof (value) * 8 - magnitude); return (value >> magnitude) | (value << (sizeof (value) * 8 - magnitude));
} }

View File

@ -145,7 +145,7 @@ template <typename T, unsigned I, unsigned E> \
fixed<T,I,E> \ fixed<T,I,E> \
fixed<T,I,E>::operator OP (integer_type val) const \ fixed<T,I,E>::operator OP (integer_type val) const \
{ \ { \
return fixed<T,I,E>::from_native (m_value OP val << E); \ return fixed<T,I,E>::from_native (m_value OP (native_type{val} << E)); \
} }
SIMPLE_INTEGER_LIT(+) SIMPLE_INTEGER_LIT(+)

View File

@ -24,7 +24,15 @@
#include <iosfwd> #include <iosfwd>
namespace util { namespace util {
template <typename T, unsigned I, unsigned E> template <
// whether the type is signed or unsigned. supply an appropriately
// signed type here; it won't be used for anything else.
typename T,
// how many bits total are used for the integral component
unsigned I,
// how many bits are used for the fractional component
unsigned E
>
class [[gnu::packed]] fixed { class [[gnu::packed]] fixed {
public: public:
static_assert (I > 0); static_assert (I > 0);

View File

@ -76,9 +76,9 @@ jsonish::parse_number (const std::function<callback_t> &cb,
++cursor; ++cursor;
auto digit_start = cursor; auto digit_start = cursor;
while (cursor != last && ('0' <= *cursor && *cursor <= '9' || while (cursor != last && ((('0' <= *cursor) && (*cursor <= '9')) ||
'a' <= *cursor && *cursor <= 'f' || (('a' <= *cursor) && (*cursor <= 'f')) ||
'A' <= *cursor && *cursor <= 'F')) (('A' <= *cursor) && (*cursor <= 'F'))))
++cursor; ++cursor;
if (digit_start == cursor) if (digit_start == cursor)
throw parse_error {cursor}; throw parse_error {cursor};

View File

@ -425,7 +425,7 @@ namespace util {
bool bool
samesign (T a, T b) samesign (T a, T b)
{ {
return a < 0 && b < 0 || a > 0 && b > 0; return (a >= 0 && b >= 0) || (a <= 0 && b <= 0);
} }