Closed Bug 1258175 Opened 4 years ago Closed 4 years ago

Remove -Wunreachable-code-return and -Wunreachable-code-aggressive flags

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(firefox48 fixed)

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(1 file)

compiler-opts.m4's check for `MOZ_CXX_SUPPORTS_WARNING(-W, unreachable-code-return, ac_cxx_has_wunreachable_code_return)` is broken. The C/C++ code that configure emits for MOZ_CXX_SUPPORTS_WARNING() actually contains a -Wunreachable-code-return warning and, thus, doesn't actually detect that clang supports the -Wunreachable-code-return flag.

This configure code in MOZ_CXX_SUPPORTS_WARNING():

  AC_TRY_COMPILE([],
                 [return(0);],
                 $3="yes",
                 $3="no")

generates something like:

  int main() {
  return(0);
  ; return 0; }

where the second return, automatically emitted by configure, is unreachable and causes a -Wunreachable-code-return warning.

The fix is to remove the redundant return(0) from MOZ_CXX_SUPPORTS_WARNING(). This allows clang's -Wunreachable-code-return flag to be detected, but then -Wunreachable-code-return breaks other configure checks, including third-party libraries' configure checks (in particular jemalloc) that also have redundant `return(0)`. So all the third-party libraries' configure checks would need to be fixed upstream, which seems like more hassle than the value of the -Wunreachable-code-return warnings. So I propose we just remove the flag. :)

This patch also:

* removes the -Wunreachable-code-aggressive check because the flag enables -Wunreachable-code-return.

* replaces the MOZ_CXX_SUPPORTS_WARNING() check for -Wunreachable-code because both clang and gcc support -Wunreachable-code (though it is a no-op with gcc) so we can just unconditionally add -Wunreachable-code warning to _WARNINGS_CXXFLAGS.
Attachment #8732587 - Flags: review?(mh+mozilla)
Comment on attachment 8732587 [details] [diff] [review]
remove-Wunreachable-code-return.patch

Review of attachment 8732587 [details] [diff] [review]:
-----------------------------------------------------------------

A part (if not the whole) of comment 0 should go into the commit message.
Attachment #8732587 - Flags: review?(mh+mozilla) → review+
Thanks. I'll include comment 0 in my commit message.
https://hg.mozilla.org/mozilla-central/rev/eb458f5d7b32
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.