Bug 1766364 - Fix unreachable-code warnings in Windows builds. r=mhowell,emilio,rkraesig

layout/base/nsLayoutUtils.cpp(9615,9): error: code will never be executed [-Werror,-Wunreachable-code]
        aDocument->ShouldAvoidNativeTheme();
        ^~~~~~~~~
layout/base/nsLayoutUtils.cpp(9613,9): note: silence by adding parentheses to mark code as explicitly dead
        true ||
        ^
        /* DISABLES CODE */ ( )
widget/windows/nsPrintSettingsWin.cpp(305,9): error: fallthrough annotation in unreachable code [-Werror,-Wunreachable-code-fallthrough]
        [[fallthrough]];
        ^
widget/windows/nsPrinterWin.cpp(165,9): error: fallthrough annotation in unreachable code [-Werror,-Wunreachable-code-fallthrough]
        [[fallthrough]];
        ^

Differential Revision: https://phabricator.services.mozilla.com/D144662
This commit is contained in:
Mike Hommey 2022-04-26 22:12:09 +00:00
parent bd9c7d6105
commit ed8eeb522c
4 changed files with 6 additions and 7 deletions

View File

@ -64,7 +64,7 @@ add_warning("-Wtype-limits")
check_and_add_warning("-Wno-error=tautological-type-limit-compare")
# catches some dead code
add_warning("-Wunreachable-code", when=not_clang_cl)
add_warning("-Wunreachable-code")
check_and_add_warning("-Wunreachable-code-return")
# catches parameters that are set but not read

View File

@ -9615,9 +9615,10 @@ void nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont,
aFontID == LookAndFeel::FontID::MozList) {
const bool isWindowsOrNonNativeTheme =
#ifdef XP_WIN
true ||
#endif
true;
#else
aDocument->ShouldAvoidNativeTheme();
#endif
if (isWindowsOrNonNativeTheme) {
// For textfields, buttons and selects, we use whatever font is defined by

View File

@ -301,8 +301,7 @@ void nsPrintSettingsWin::CopyFromNative(HDC aHdc, DEVMODEW* aDevMode) {
if (aDevMode->dmFields & DM_DUPLEX) {
switch (aDevMode->dmDuplex) {
default:
MOZ_ASSERT_UNREACHABLE("bad value for dmDuplex field");
[[fallthrough]];
MOZ_FALLTHROUGH_ASSERT("bad value for dmDuplex field");
case DMDUP_SIMPLEX:
mDuplex = kDuplexNone;
break;

View File

@ -161,8 +161,7 @@ static void DevmodeToSettingsInitializer(
if (aDevmode->dmFields & DM_DUPLEX) {
switch (aDevmode->dmDuplex) {
default:
MOZ_ASSERT_UNREACHABLE("bad value for dmDuplex field");
[[fallthrough]];
MOZ_FALLTHROUGH_ASSERT("bad value for dmDuplex field");
case DMDUP_SIMPLEX:
aSettingsInitializer.mDuplex = nsPrintSettings::kDuplexNone;
break;