Bug 1415470 - build: Enable VS2017 C5038 initializer list order warnings (like gcc -Wreorder). r?glandium draft
authorChris Peterson <cpeterson@mozilla.com>
Tue, 07 Nov 2017 19:52:10 -0800
changeset 696744 995d7bc2c4fd372572115c685671055b9a5b4dcd
parent 696743 d79c324dd748ddb92a2aa113d081fbed8b2a8937
child 739912 2efe17dc810fc3933a437e4048a20f5ab7307829
push id88775
push usercpeterson@mozilla.com
push dateSat, 11 Nov 2017 04:30:06 +0000
reviewersglandium
bugs1415470, 15063
milestone58.0a1
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,21 @@ 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: initializer list order warnings
+            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,21 @@ 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: initializer list order warnings
+            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']