Bug 1356843 - Enable -Wcomma clang warnings. r?glandium draft
authorChris Peterson <cpeterson@mozilla.com>
Sat, 08 Apr 2017 12:36:48 -0700
changeset 563349 d99ad92ef75ae4bbf0b7bc945f2c15179c5b29b0
parent 563348 007462b7dc00e188382982ddf4a03f0c43be83e3
child 624435 91be48126dbdc4f9e1d49af2d11d3f70c1dad72b
push id54258
push usercpeterson@mozilla.com
push dateSun, 16 Apr 2017 05:52:14 +0000
reviewersglandium
bugs1356843
milestone55.0a1
Bug 1356843 - Enable -Wcomma clang warnings. r?glandium Warn about possible misuse of the comma operator such as between two statements or to call a function for side effects within an expression. Only enable these -Wcomma warnings for C++ code because there are almost two hundred -Wcomma warnings in third-party C libraries. I reviewed the C warnings and confirmed none of them were latent bugs. We won't fix these libraries' warnings so they are just noise. MozReview-Commit-ID: 1JXJumg6DsJ
build/moz.configure/warnings.configure
gfx/harfbuzz/src/moz.build
--- a/build/moz.configure/warnings.configure
+++ b/build/moz.configure/warnings.configure
@@ -56,16 +56,19 @@ check_and_add_gcc_warning('-Wclass-varar
 check_and_add_gcc_warning('-Wloop-analysis')
 
 # catches C++ version forward-compat issues
 check_and_add_gcc_warning('-Wc++11-compat-pedantic', cxx_compiler)
 check_and_add_gcc_warning('-Wc++14-compat', cxx_compiler)
 check_and_add_gcc_warning('-Wc++14-compat-pedantic', cxx_compiler)
 check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler)
 
+# catches suspicious uses of the comma operator
+check_and_add_gcc_warning('-Wcomma', cxx_compiler)
+
 # catches unintentional switch case fallthroughs
 check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler)
 
 # catches expressions used as a null pointer constant
 # XXX: at the time of writing, the version of clang used on the OS X test
 # machines has a bug that causes it to reject some valid files if both
 # -Wnon-literal-null-conversion and -Wsometimes-uninitialized are
 # specified. We work around this by instead using
--- a/gfx/harfbuzz/src/moz.build
+++ b/gfx/harfbuzz/src/moz.build
@@ -69,16 +69,19 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']
     UNIFIED_SOURCES += [
         'hb-glib.cc',
     ]
     CXXFLAGS += CONFIG['GLIB_CFLAGS']
 
 # We allow warnings for third-party code that can be updated from upstream.
 ALLOW_COMPILER_WARNINGS = True
 
+if CONFIG['CLANG_CXX']:
+    CXXFLAGS += ['-Wno-comma']
+
 FINAL_LIBRARY = 'gkmedias'
 
 DEFINES['PACKAGE_VERSION'] = '"moz"'
 DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"'
 DEFINES['HAVE_OT'] = 1
 DEFINES['HB_NO_MT'] = True
 DEFINES['HB_NO_UNICODE_FUNCS'] = True
 # Cancel the effect of the -DDEBUG macro if present,