Bug 1508927 - Enable clang's -Wbitfield-enum-conversion warnings. r=glandium
authorChris Peterson <cpeterson@mozilla.com>
Tue, 27 Nov 2018 02:01:48 +0000
changeset 448964 6feb94524b7e519e720d7cccc3fa9cccc51f904e
parent 448963 a27c599bed805807826d3bfd7f7be40c7e629759
child 448965 77f0c6b51d009e85a366998fe694a9b3c35ca2c6
push id35139
push userccoroiu@mozilla.com
push dateSat, 01 Dec 2018 02:30:08 +0000
treeherdermozilla-central@22425b629a9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1508927, 1485179
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508927 - Enable clang's -Wbitfield-enum-conversion warnings. r=glandium https://clang.llvm.org/docs/DiagnosticsReference.html#wbitfield-enum-conversion This clang warning caught a real layout bug related to implicitly truncated enums in the table border style code (bug 1485179): layout/tables/nsTableFrame.cpp:5318:14 [-Wbitfield-enum-conversion] bit-field 'ownerElem' is not wide enough to store all enumerators of 'BCBorderOwner' layout/tables/nsTableFrame.cpp:5358:16 [-Wbitfield-enum-conversion] bit-field 'ownerElem' is not wide enough to store all enumerators of 'BCBorderOwner' layout/tables/nsTableFrame.cpp:5374:18 [-Wbitfield-enum-conversion] bit-field 'subElem' is not wide enough to store all enumerators of 'BCBorderOwner' layout/tables/nsTableFrame.cpp:5385:18 [-Wbitfield-enum-conversion] bit-field 'subElem' is not wide enough to store all enumerators of 'BCBorderOwner' Also update the comment linking to clang and gcc's warning documentation. Differential Revision: https://phabricator.services.mozilla.com/D12513
build/moz.configure/warnings.configure
--- a/build/moz.configure/warnings.configure
+++ b/build/moz.configure/warnings.configure
@@ -9,21 +9,25 @@ js_option('--enable-warnings-as-errors',
           help='{Enable|Disable} treating warnings as errors')
 
 add_old_configure_assignment(
     'MOZ_ENABLE_WARNINGS_AS_ERRORS',
     depends('--enable-warnings-as-errors')(lambda x: bool(x)))
 
 
 # GCC/Clang warnings:
-# https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Warning-Options.html
+# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+# https://clang.llvm.org/docs/DiagnosticsReference.html
 
 # lots of useful warnings
 add_gcc_warning('-Wall')
 
+# catch implicit truncation of enum values assigned to smaller bit fields
+check_and_add_gcc_warning('-Wbitfield-enum-conversion')
+
 # catches bugs, e.g. "if (c); foo();", few false positives
 add_gcc_warning('-Wempty-body')
 
 # catches return types with qualifiers like const
 add_gcc_warning('-Wignored-qualifiers')
 
 # function declaration hides virtual function from base class
 add_gcc_warning('-Woverloaded-virtual', cxx_compiler)