Fallthrough in switch statements must now be explicit on linux; please help turning this on on your platform

365 views
Skip to first unread message

Nico Weber

unread,
Feb 1, 2018, 2:55:42 PM2/1/18
to Chromium-dev, blink-dev
Hi,

as of #533729, the compiler will emit an -Wimplicit-fallthrough warning if a case or default block in a switch statement falls through into another (non-empty) case or default block.

If fallthrough is intended, explicitly say "FALLTHROUGH;" (see cs.chromium.org for many examples.) Else, insert the missing break that you forgot.

The warning is currently enabled in release linux builds. https://chromium-review.googlesource.com/c/chromium/src/+/896718 will enable it for debug builds as well, it should hopefully land later today.

I'd appreciate help in getting the warning enabled on more platforms (android, windows, mac, chromecast, headless, ...). If you're interested in helping out, find "Wimplicit-fallthrough" in build/config/compiler/BUILD.gn , tweak the conditional above it so it's true on your platform, build, and fix warnings you run into. https://crbug.com/177475 has many many example CLs. Maybe announce on the bug that you're working on a platform, to reduce duplicate work.

Nico


ps: The warning looks like so (so that search can find this mail if you search for the warning text).


../../net/http/http_pipelined_host_impl.cc:159:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case PIPELINE_UNKNOWN:
    ^
../../net/http/http_pipelined_host_impl.cc:159:5: note: insert 'FALLTHROUGH;' to silence this warning
    case PIPELINE_UNKNOWN:
    ^
    FALLTHROUGH
../../net/http/http_pipelined_host_impl.cc:159:5: note: insert 'break;' to avoid fall-through
    case PIPELINE_UNKNOWN:
    ^
    break;

Jakob Kummerow

unread,
Feb 1, 2018, 3:58:16 PM2/1/18
to Nico Weber, chromium-dev, blink-dev
In light of crbug.com/805946, what would be the best way to add FALLTHROUGH annotations and -Wimplicit-fallthrough warnings to other DEPS'ed-in projects (like V8)?


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGbLiFCRq2gP7XBfkyizVEwFwgqWJaHF4XV_CgRBfpGS-co%2BA%40mail.gmail.com.

Nico Weber

unread,
Feb 1, 2018, 4:07:35 PM2/1/18
to Jakob Kummerow, Chromium-dev, blink-dev
https://bugs.chromium.org/p/chromium/issues/detail?id=807632 comment 0 has an outline. Please comment on that bug if that's not sufficient :-)

Nico Weber

unread,
Feb 9, 2018, 9:27:03 AM2/9/18
to Chromium-dev, blink-dev
This warning is now enabled in all build configurations on all platforms.
Reply all
Reply to author
Forward
0 new messages