From 42b3b8a6954465dcf519918acd1d4ab4a7848b83 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 15 Apr 2019 15:26:05 -0400 Subject: [PATCH] Fix reorder warnings (dotnet/core-setup#5821) Add compiler flags to fail any builds that produce that warning. The member initialization list is always evaluated in the order the members are delcared in the class, not the order in which they are listed in the member initialization list. So modify the member initialization lists to match the order in which they will be evaluated. Commit migrated from https://github.com/dotnet/core-setup/commit/dcbb048073e3745df48e52d0619648f7aae8fa3d --- src/installer/corehost/cli/apphost/bundle/bundle_runner.h | 8 ++++---- src/installer/corehost/cli/deps_format.h | 4 ++-- src/installer/corehost/cli/fx_reference.h | 10 +++++----- src/installer/corehost/cli/fxr/corehost_init.cpp | 10 +++++----- src/installer/corehost/cli/hostpolicy/args.cpp | 8 ++++---- src/installer/corehost/cli/hostpolicy/args.h | 2 +- src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp | 4 ++-- src/installer/corehost/cli/hostpolicy/deps_resolver.h | 4 ++-- src/installer/corehost/cli/ijwhost/bootstrap_thunk_chunk.cpp | 2 +- src/installer/settings.cmake | 2 ++ 10 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/installer/corehost/cli/apphost/bundle/bundle_runner.h b/src/installer/corehost/cli/apphost/bundle/bundle_runner.h index 1f87dbd..3821227 100644 --- a/src/installer/corehost/cli/apphost/bundle/bundle_runner.h +++ b/src/installer/corehost/cli/apphost/bundle/bundle_runner.h @@ -16,10 +16,10 @@ namespace bundle { public: bundle_runner_t(const pal::string_t& bundle_path) - :m_bundle_path(bundle_path), - m_bundle_stream(nullptr), - m_manifest(nullptr), - m_num_embedded_files(0) + : m_bundle_stream(nullptr) + , m_manifest(nullptr) + , m_num_embedded_files(0) + , m_bundle_path(bundle_path) { } diff --git a/src/installer/corehost/cli/deps_format.h b/src/installer/corehost/cli/deps_format.h index 135ebe2..a8e6e65 100644 --- a/src/installer/corehost/cli/deps_format.h +++ b/src/installer/corehost/cli/deps_format.h @@ -29,8 +29,8 @@ public: typedef str_to_vector_map_t rid_fallback_graph_t; deps_json_t() - : m_valid(false) - , m_file_exists(false) + : m_file_exists(false) + , m_valid(false) { } diff --git a/src/installer/corehost/cli/fx_reference.h b/src/installer/corehost/cli/fx_reference.h index ce4207b..097cfdc 100644 --- a/src/installer/corehost/cli/fx_reference.h +++ b/src/installer/corehost/cli/fx_reference.h @@ -14,14 +14,14 @@ class fx_reference_t { public: fx_reference_t() - : fx_name(_X("")) - , fx_version(_X("")) - , fx_version_number() - , has_patch_roll_fwd(false) + : has_patch_roll_fwd(false) , patch_roll_fwd(false) , has_roll_fwd_on_no_candidate_fx(false) - , use_exact_version(false) , roll_fwd_on_no_candidate_fx((roll_fwd_on_no_candidate_fx_option)0) + , use_exact_version(false) + , fx_name(_X("")) + , fx_version(_X("")) + , fx_version_number() { } const pal::string_t& get_fx_name() const diff --git a/src/installer/corehost/cli/fxr/corehost_init.cpp b/src/installer/corehost/cli/fxr/corehost_init.cpp index 7881fbe..4a26793 100644 --- a/src/installer/corehost/cli/fxr/corehost_init.cpp +++ b/src/installer/corehost/cli/fxr/corehost_init.cpp @@ -21,17 +21,17 @@ corehost_init_t::corehost_init_t( const std::vector& probe_paths, const host_mode_t mode, const fx_definition_vector_t& fx_definitions) - : m_host_command(host_command) - , m_host_info_host_path(host_info.host_path) - , m_host_info_dotnet_root(host_info.dotnet_root) - , m_host_info_app_path(host_info.app_path) + : m_tfm(get_app(fx_definitions).get_runtime_config().get_tfm()) , m_deps_file(deps_file) , m_additional_deps_serialized(additional_deps_serialized) , m_is_framework_dependent(get_app(fx_definitions).get_runtime_config().get_is_framework_dependent()) , m_probe_paths(probe_paths) , m_host_mode(mode) , m_host_interface() - , m_tfm(get_app(fx_definitions).get_runtime_config().get_tfm()) + , m_host_command(host_command) + , m_host_info_host_path(host_info.host_path) + , m_host_info_dotnet_root(host_info.dotnet_root) + , m_host_info_app_path(host_info.app_path) { make_cstr_arr(m_probe_paths, &m_probe_paths_cstr); diff --git a/src/installer/corehost/cli/hostpolicy/args.cpp b/src/installer/corehost/cli/hostpolicy/args.cpp index 3855be1..26cafe6 100644 --- a/src/installer/corehost/cli/hostpolicy/args.cpp +++ b/src/installer/corehost/cli/hostpolicy/args.cpp @@ -6,14 +6,14 @@ #include arguments_t::arguments_t() - : managed_application(_X("")) - , host_mode(host_mode_t::invalid) + : host_mode(host_mode_t::invalid) , host_path(_X("")) , app_root(_X("")) + , deps_path(_X("")) + , core_servicing(_X("")) + , managed_application(_X("")) , app_argc(0) , app_argv(nullptr) - , core_servicing(_X("")) - , deps_path(_X("")) { } diff --git a/src/installer/corehost/cli/hostpolicy/args.h b/src/installer/corehost/cli/hostpolicy/args.h index db1212b..a4a4fc2 100644 --- a/src/installer/corehost/cli/hostpolicy/args.h +++ b/src/installer/corehost/cli/hostpolicy/args.h @@ -38,8 +38,8 @@ struct probe_config_t : probe_dir(probe_dir) , probe_deps_json(probe_deps_json) , fx_level(fx_level) - , only_serviceable_assets(only_serviceable_assets) , only_runtime_assets(only_runtime_assets) + , only_serviceable_assets(only_serviceable_assets) , probe_publish_dir(probe_publish_dir) { } diff --git a/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp b/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp index daab2a2..4eee21d 100644 --- a/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp +++ b/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp @@ -9,9 +9,9 @@ #include "breadcrumbs.h" breadcrumb_writer_t::breadcrumb_writer_t(bool enabled, const std::unordered_set &files) - : m_status(false) + : m_files(files) , m_enabled(enabled) - , m_files(files) + , m_status(false) { if (enabled && !pal::get_default_breadcrumb_store(&m_breadcrumb_store)) { diff --git a/src/installer/corehost/cli/hostpolicy/deps_resolver.h b/src/installer/corehost/cli/hostpolicy/deps_resolver.h index f318a4a..634c8abd 100644 --- a/src/installer/corehost/cli/hostpolicy/deps_resolver.h +++ b/src/installer/corehost/cli/hostpolicy/deps_resolver.h @@ -49,10 +49,10 @@ public: bool is_framework_dependent) : m_fx_definitions(fx_definitions) , m_app_dir(args.app_root) + , m_host_mode(args.host_mode) , m_managed_app(args.managed_application) - , m_is_framework_dependent(is_framework_dependent) , m_core_servicing(args.core_servicing) - , m_host_mode(args.host_mode) + , m_is_framework_dependent(is_framework_dependent) { int lowest_framework = m_fx_definitions.size() - 1; int root_framework = -1; diff --git a/src/installer/corehost/cli/ijwhost/bootstrap_thunk_chunk.cpp b/src/installer/corehost/cli/ijwhost/bootstrap_thunk_chunk.cpp index 3eadffd..5df0348 100644 --- a/src/installer/corehost/cli/ijwhost/bootstrap_thunk_chunk.cpp +++ b/src/installer/corehost/cli/ijwhost/bootstrap_thunk_chunk.cpp @@ -8,7 +8,7 @@ //================================================================================= // Ctor bootstrap_thunk_chunk::bootstrap_thunk_chunk(size_t numThunks, pal::dll_t dll) - : m_numThunks(numThunks), m_dll(dll), m_next(NULL) + : m_dll(dll), m_numThunks(numThunks), m_next(NULL) { #ifdef _DEBUG memset(m_thunks, 0, m_numThunks * sizeof(bootstrap_thunk)); diff --git a/src/installer/settings.cmake b/src/installer/settings.cmake index 98768ad..d594a13 100644 --- a/src/installer/settings.cmake +++ b/src/installer/settings.cmake @@ -158,6 +158,7 @@ if(WIN32) add_compile_options(/DEBUG) add_compile_options(/GS) add_compile_options(/W1) + add_compile_options(/we5038) # make reorder warnings into errors add_compile_options(/Zc:inline) add_compile_options(/fp:precise) add_compile_options(/EHsc) @@ -189,6 +190,7 @@ if(WIN32) set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") else() add_compile_options(-Wno-unused-local-typedef) + add_compile_options(-Werror=reorder) endif() # Older CMake doesn't support CMAKE_CXX_STANDARD and GCC/Clang need a switch to enable C++ 11 -- 2.7.4