Bug 1356843 - Enable -Wcomma clang warnings. r=glandium draft
authorChris Peterson <cpeterson@mozilla.com>
Sat, 08 Apr 2017 12:36:48 -0700
changeset 563965 339eb057a6c8b16d270d023013244672461d32ff
parent 563964 e4e203fbfd6be50b9299851f11c1e87ec048e3ae
child 563966 206a327410b1ed367a9deae233c10578e7d8baf2
push id54487
push usercpeterson@mozilla.com
push dateTue, 18 Apr 2017 06:09:29 +0000
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
--- a/build/moz.configure/warnings.configure
+++ b/build/moz.configure/warnings.configure
@@ -56,16 +56,19 @@ check_and_add_gcc_warning('-Wclass-varar
 # 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