Bug 1415470 - build: Enable VS2017 C5038 initializer list order warnings (like gcc -Wreorder). r=glandium
authorChris Peterson <cpeterson@mozilla.com>
Tue, 07 Nov 2017 19:52:10 -0800
changeset 391959 7e35281e0eafbc99ee94d182dfb11d4492f89120
parent 391958 819ad76c63771b74401946c31b136a37cffbf611
child 391960 7613f8e20ad525e183b9e5a237cb5725fbe3f630
push id32909
push usercbrindusan@mozilla.com
push dateWed, 15 Nov 2017 22:25:14 +0000
treeherdermozilla-central@f41930a869a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1415470, 15063
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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<Microsoft::WRL::Wrappers::HandleTraits::SemaphoreTraits>::sync_' will be initialized after data member 'Microsoft::WRL::Wrappers::Details::SyncLockWithStatusT<Microsoft::WRL::Wrappers::HandleTraits::SemaphoreTraits>::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
gfx/angle/moz.build
gfx/angle/src/libANGLE/moz.build
gfx/angle/src/libGLESv2/moz.build
js/src/old-configure.in
media/webrtc/moz.build
old-configure.in
widget/windows/moz.build
--- a/gfx/angle/moz.build
+++ b/gfx/angle/moz.build
@@ -155,16 +155,19 @@ if CONFIG['GNU_CXX']:
             '-Wno-unused-private-field',
         ]
     else:
         CXXFLAGS += [
             '-Wno-shadow-compatible-local',
             '-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']]
 
 DEFINES['_CRT_SECURE_NO_DEPRECATE'] = True
 DEFINES['_HAS_EXCEPTIONS'] = 0
 
 if not CONFIG['MOZ_DEBUG']:
     DEFINES['_SECURE_SCL'] = 0
--- a/gfx/angle/src/libANGLE/moz.build
+++ b/gfx/angle/src/libANGLE/moz.build
@@ -358,16 +358,17 @@ if CONFIG['GNU_CXX']:
             '-Wno-shadow-compatible-local',
             '-Wno-shadow-local',
         ]
 
 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']:
     LOCAL_INCLUDES += ['%' + '%s/include/' % CONFIG['MOZ_DIRECTX_SDK_PATH']]
 
 DEFINES['_CRT_SECURE_NO_DEPRECATE'] = True
 DEFINES['_HAS_EXCEPTIONS'] = 0
 
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -34,16 +34,19 @@ if CONFIG['GNU_CXX']:
             '-Wno-unused-private-field',
         ]
     else:
         CXXFLAGS += [
             '-Wno-shadow-compatible-local',
             '-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']]
 
 DEFINES['_CRT_SECURE_NO_DEPRECATE'] = True
 DEFINES['_HAS_EXCEPTIONS'] = 0
 
 if not CONFIG['MOZ_DEBUG']:
     DEFINES['_SECURE_SCL'] = 0
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -175,16 +175,26 @@ case "$target" in
         changequote([,])
 
         _MSC_VER=`echo ${CC_VERSION} | cut -c 1-2,4-5`
 
         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
         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
 
         # C5026: move constructor was implicitly defined as deleted
         CXXFLAGS="$CXXFLAGS -wd5026"
 
         # C5027: move assignment operator was implicitly defined as deleted
--- a/media/webrtc/moz.build
+++ b/media/webrtc/moz.build
@@ -89,17 +89,20 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']:
     GYP_DIRS['trunk/third_party/gflags'].variables = gyp_vars_copy
     GYP_DIRS['trunk/third_party/gflags'].sandbox_vars['COMPILE_FLAGS'] = {'WARNINGS_AS_ERRORS': []}
 
     if CONFIG['_MSC_VER']:
         # Avoid warnings from third-party code that we can not modify.
         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 += [
             'signaling/gtest',
             'trunk/gtest',
         ]
 
     if CONFIG['FUZZING']:
--- a/old-configure.in
+++ b/old-configure.in
@@ -187,16 +187,26 @@ case "$target" in
         MSVC_C_RUNTIME_DLL=vcruntime140.dll
         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
 
         MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
         if test -n "$MSVC_HAS_DIA_SDK"; then
             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"
 
         # C5027: move assignment operator was implicitly defined as deleted
         CXXFLAGS="$CXXFLAGS -wd5027"
 
         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -142,8 +142,12 @@ for var in ('MOZ_ENABLE_D3D10_LAYER'):
 
 RESFILE = 'widget.res'
 
 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']