From 768b96f58b9de81d61ce957e8df970eb3b212f62 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Tue, 7 Nov 2017 19:52:10 -0800 Subject: [PATCH] Bug 1415470 - build: Enable VS2017 C5038 initializer list order warnings (like gcc -Wreorder). r=glandium C5038 is a new warning in VS2017, similar to gcc and clang's -Wreorder, which is enabled by -Wall. We should enable C5038 so Windows developers can see these warnings locally instead of when gcc and clang fail with warnings-as-errors on Try. https://blogs.msdn.microsoft.com/vcblog/2017/07/21/diagnostic-improvements-in-vs2017-15-3-0/ We need to suppress C5038 warnings from Windows Runtime Library header files (wrl.h) included in ANGLE and widget/windows: z:\build\build\src\vs2017_15.4.2\SDK\Include\10.0.15063.0\winrt\wrl\wrappers\corewrappers.h(515): error C5038: data member 'Microsoft::WRL::Wrappers::Details::SyncLockWithStatusT::sync_' will be initialized after data member 'Microsoft::WRL::Wrappers::Details::SyncLockWithStatusT::status_' ... And suppress C5038 warnings in upstream webrtc code: media/webrtc/trunk/webrtc/modules/video_capture/windows/BaseFilter.cpp(176): error C5038: data member 'mozilla::media::BaseFilter::mClsId' will be initialized after data member 'mozilla::media::BaseFilter::mState' media/webrtc/trunk/webrtc/modules/video_capture/windows/BasePin.cpp(169): error C5038: data member 'mozilla::media::BasePin::mFilter' will be initialized after data member 'mozilla::media::BasePin::mLock' media/webrtc/trunk/webrtc/modules/video_capture/windows/BasePin.cpp(170): error C5038: data member 'mozilla::media::BasePin::mLock' will be initialized after data member 'mozilla::media::BasePin::mName' media/webrtc/trunk/webrtc/modules/video_capture/windows/BasePin.cpp(172): error C5038: data member 'mozilla::media::BasePin::mDirection' will be initialized after data member 'mozilla::media::BasePin::mQualitySink' MozReview-Commit-ID: BMDVkvQXNoq --HG-- extra : rebase_source : 0d5ede9530d0d0750b8fffdc1cdfdc646ec8f22a --- gfx/angle/moz.build | 3 +++ gfx/angle/src/libANGLE/moz.build | 1 + gfx/angle/src/libGLESv2/moz.build | 3 +++ js/src/old-configure.in | 10 ++++++++++ media/webrtc/moz.build | 5 ++++- old-configure.in | 10 ++++++++++ widget/windows/moz.build | 4 ++++ 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gfx/angle/moz.build b/gfx/angle/moz.build index f006df671ffb..2960883a9b06 100644 --- a/gfx/angle/moz.build +++ b/gfx/angle/moz.build @@ -160,6 +160,9 @@ if CONFIG['GNU_CXX']: '-Wno-shadow-local', ] +if CONFIG['_MSC_VER']: + CXXFLAGS += ['-wd5038'] # C5038: initializer list order warnings + if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']] diff --git a/gfx/angle/src/libANGLE/moz.build b/gfx/angle/src/libANGLE/moz.build index 7f80fb814cf4..b6ce40537d06 100755 --- a/gfx/angle/src/libANGLE/moz.build +++ b/gfx/angle/src/libANGLE/moz.build @@ -363,6 +363,7 @@ if CONFIG['_MSC_VER'] and not CONFIG['CLANG_CL']: CXXFLAGS += [ '-wd4018', # '>' : signed/unsigned mismatch '-wd4530', # C++ exception handler used, without /EHsc + '-wd5038', # C5038: initializer list order warnings ] if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build index 5e1a663cbc24..ecd5fab531fe 100644 --- a/gfx/angle/src/libGLESv2/moz.build +++ b/gfx/angle/src/libGLESv2/moz.build @@ -39,6 +39,9 @@ if CONFIG['GNU_CXX']: '-Wno-shadow-local', ] +if CONFIG['_MSC_VER']: + CXXFLAGS += ['-wd5038'] # C5038: initializer list order warnings + if CONFIG['MOZ_DIRECTX_SDK_PATH'] and not CONFIG['MOZ_HAS_WINSDK_WITH_D3D']: LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']] diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 2518a0fb53a0..bf178da88d1f 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -180,6 +180,16 @@ case "$target" in AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS) AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI. + if test "$_MSC_VER" -ge "1910"; then # VS2017+ + # C5038: Enable initializer list order warnings + # The -w1#### flag treats warning C#### as if it was a warning level + # 1 warning, and thus enables it because we enable /W3 warnings. We + # don't use -we#### because it would enable warning C#### but treat + # it as an error, even in third-party code. + # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level + CXXFLAGS="$CXXFLAGS -w15038" + fi + _CC_SUITE=14 MSVC_C_RUNTIME_DLL=vcruntime140.dll MSVC_CXX_RUNTIME_DLL=msvcp140.dll diff --git a/media/webrtc/moz.build b/media/webrtc/moz.build index c34e88a0e832..9e33a7674953 100644 --- a/media/webrtc/moz.build +++ b/media/webrtc/moz.build @@ -94,7 +94,10 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']: if CONFIG['CLANG_CL']: CXXFLAGS += ['-Wno-invalid-source-encoding'] else: - CXXFLAGS += ['-validate-charset-'] + CXXFLAGS += [ + '-validate-charset-', + '-wd5038', # C5038 initializer list order warnings + ] if CONFIG['ENABLE_TESTS']: TEST_DIRS += [ diff --git a/old-configure.in b/old-configure.in index cf949cc27959..35571d2a2397 100644 --- a/old-configure.in +++ b/old-configure.in @@ -192,6 +192,16 @@ case "$target" in AC_DEFINE(MSVC_HAS_DIA_SDK) fi + if test "$_MSC_VER" -ge "1910"; then # VS2017+ + # C5038: Enable initializer list order warnings + # The -w1#### flag treats warning C#### as if it was a warning level + # 1 warning, and thus enables it because we enable /W3 warnings. We + # don't use -we#### because it would enable warning C#### but treat + # it as an error, even in third-party code. + # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level + CXXFLAGS="$CXXFLAGS -w15038" + fi + # C5026: move constructor was implicitly defined as deleted CXXFLAGS="$CXXFLAGS -wd5026" diff --git a/widget/windows/moz.build b/widget/windows/moz.build index 70e86cf2a62b..8215ca5efd7f 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -147,3 +147,7 @@ CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] OS_LIBS += [ 'rpcrt4', ] + +if CONFIG['_MSC_VER']: + # C5038: Suppress initializer list order warnings from wrl.h + SOURCES['WindowsUIUtils.cpp'].flags += ['-wd5038']