Commit 3bb8f57d authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1766370 - Fix bitfield-enum-conversion warnings in Windows builds. r=jandem

js/src/jit/x86-shared/Architecture-x86-shared.h(326,9): error: signed bit-field 'reg_' needs an extra bit to represent the largest positive enumerators of 'XMMRegisterID' [-Werror,-Wbitfield-enum-conversion]
      : reg_(Codes::Encoding(r)), type_(k), isInvalid_(false) {}
        ^
js/src/jit/x86-shared/Architecture-x86-shared.h(310,3): note: consider making the bitfield type unsigned
  Codes::Encoding reg_ : 5;
  ^~~~~~~~~~~~~~~
(...)
js/src/jit/RangeAnalysis.h(378,28): error: signed bit-field 'canHaveFractionalPart_' needs an extra bit to represent the largest positive enumerators of 'FractionalPartFlag' [-Werror,-Wbitfield-enum-conversion]
    canHaveFractionalPart_ = canHaveFractionalPart;
                           ^
js/src/jit/RangeAnalysis.h(227,25): note: consider making the bitfield type unsigned
  MOZ_INIT_OUTSIDE_CTOR FractionalPartFlag canHaveFractionalPart_ : 1;
                        ^~~~~~~~~~~~~~~~~~
(...)
js/src/jit/RangeAnalysis.h(379,24): error: signed bit-field 'canBeNegativeZero_' needs an extra bit to represent the largest positive enumerators of 'NegativeZeroFlag' [-Werror,-Wbitfield-enum-conversion]
    canBeNegativeZero_ = canBeNegativeZero;
                       ^
js/src/jit/RangeAnalysis.h(228,25): note: consider making the bitfield type unsigned
  MOZ_INIT_OUTSIDE_CTOR NegativeZeroFlag canBeNegativeZero_ : 1;
                        ^~~~~~~~~~~~~~~~

Differential Revision: https://phabricator.services.mozilla.com/D144664
parent 42c56288
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ add_warning("-Wall", when=not_clang_cl)
add_warning("-W3", when=depends(c_compiler)(lambda c: c.type == "clang-cl"))

# catch implicit truncation of enum values assigned to smaller bit fields
check_and_add_warning("-Wbitfield-enum-conversion", when=not_clang_cl)
check_and_add_warning("-Wbitfield-enum-conversion")

# catches deprecated implicit capture of `this` in lambdas.
check_and_add_warning("-Wdeprecated-this-capture", cxx_compiler)
+2 −2
Original line number Diff line number Diff line
@@ -178,11 +178,11 @@ class Range : public TempObject {
  static const int64_t NoInt32UpperBound = int64_t(JSVAL_INT_MAX) + 1;
  static const int64_t NoInt32LowerBound = int64_t(JSVAL_INT_MIN) - 1;

  enum FractionalPartFlag {
  enum FractionalPartFlag : bool {
    ExcludesFractionalParts = false,
    IncludesFractionalParts = true
  };
  enum NegativeZeroFlag {
  enum NegativeZeroFlag : bool {
    ExcludesNegativeZero = false,
    IncludesNegativeZero = true
  };
+7 −2
Original line number Diff line number Diff line
@@ -44,8 +44,13 @@ enum RegisterID : uint8_t {

enum HRegisterID { ah = rsp, ch = rbp, dh = rsi, bh = rdi };

enum XMMRegisterID {
  xmm0,
enum XMMRegisterID
// GCC < 8.0 has a bug with bitfields of enums with an underlying type.
#if defined(__clang__) || __GNUC__ > 7
    : uint8_t
#endif
{
  xmm0 = 0,
  xmm1,
  xmm2,
  xmm3,