chasing msvc warnings

This commit is contained in:
Jean-Louis Leroy
2025-09-15 19:48:14 -04:00
parent 4b3bc74de2
commit 81690dca4a
5 changed files with 38 additions and 22 deletions

View File

@@ -29,8 +29,9 @@
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4646)
#pragma warning(disable : 4100)
#pragma warning(disable : 4646)
#pragma warning(disable : 4702) // unreachable code
#endif
namespace boost::openmethod {

View File

@@ -27,7 +27,9 @@
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4457)
#pragma warning(disable : 4456)
#pragma warning(disable : 4458)
#pragma warning(disable : 4702) // unreachable code
#endif
namespace boost::openmethod {
@@ -936,12 +938,12 @@ void registry<Policies...>::compiler::build_dispatch_table(
}
if (dim == 0) {
std::vector<overrider*> candidates;
std::vector<overrider*> overriders;
std::size_t i = 0;
for (auto& spec : m.specs) {
if (mask[i]) {
candidates.push_back(&spec);
overriders.push_back(&spec);
}
++i;
}
@@ -950,13 +952,13 @@ void registry<Policies...>::compiler::build_dispatch_table(
++trace << "select best of:\n";
indent _(trace);
for (auto& app : candidates) {
for (auto& app : overriders) {
++trace << "#" << app->spec_index << " "
<< type_name(app->info->type) << "\n";
}
}
std::vector<overrider*> dominants = candidates;
std::vector<overrider*> dominants = overriders;
std::size_t pick, remaining;
select_dominant_overriders(dominants, pick, remaining);
@@ -994,10 +996,10 @@ void registry<Policies...>::compiler::build_dispatch_table(
// -------------------------------------------------------------
// next
// First remove the dominant overriders from the candidates.
// Note that the dominants appear in the candidates in the same
// First remove the dominant overriders from the overriders.
// Note that the dominants appear in the overriders in the same
// relative order.
auto candidate = candidates.begin();
auto candidate = overriders.begin();
remaining = 0;
for (auto dominant : dominants) {
@@ -1018,7 +1020,7 @@ void registry<Policies...>::compiler::build_dispatch_table(
++trace << "for 'next', select best of:\n";
indent _(trace);
for (auto& app : candidates) {
for (auto& app : overriders) {
if (app) {
++trace << "#" << app->spec_index << " "
<< type_name(app->info->type) << "\n";
@@ -1026,7 +1028,7 @@ void registry<Policies...>::compiler::build_dispatch_table(
}
}
select_dominant_overriders(candidates, pick, remaining);
select_dominant_overriders(overriders, pick, remaining);
if constexpr (!has_n2216) {
if (remaining > 1) {
@@ -1036,7 +1038,7 @@ void registry<Policies...>::compiler::build_dispatch_table(
}
}
auto next_overrider = candidates[pick];
auto next_overrider = overriders[pick];
overrider->next = next_overrider;
++trace << "-> #" << next_overrider->spec_index << " "
@@ -1300,15 +1302,15 @@ auto registry<Policies...>::compiler::is_base(
}
template<class... Policies>
void registry<Policies...>::compiler::print(const method_report& report) const {
void registry<Policies...>::compiler::print(const method_report& r) const {
++trace;
if (report.cells) {
if (r.cells) {
// only for multi-methods, uni-methods don't have dispatch tables
++trace << report.cells << " dispatch table cells, ";
++trace << r.cells << " dispatch table cells, ";
}
trace << report.not_implemented << " not implemented, " << report.ambiguous
trace << r.not_implemented << " not implemented, " << r.ambiguous
<< " ambiguous\n";
}

View File

@@ -10,6 +10,10 @@
#include <limits>
#include <random>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4702) // unreachable code
#endif
namespace boost::openmethod {

View File

@@ -8,6 +8,11 @@
#include <stdlib.h>
#include <vector>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4702)
#endif
namespace boost::openmethod {
@@ -774,4 +779,8 @@ auto static_offset_error::write(Stream& os) const -> void {
} // namespace boost::openmethod
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // BOOST_OPENMETHOD_REGISTRY_HPP

View File

@@ -253,8 +253,8 @@ struct Animal {
Animal(const char* name, std::size_t type) : name(name), type(type) {
}
virtual auto cast_aux(std::size_t type) -> void* {
return type == static_type ? this : nullptr;
virtual auto cast_aux(std::size_t to_type) -> void* {
return to_type == static_type ? this : nullptr;
}
static constexpr std::size_t static_type = 0;
@@ -273,8 +273,8 @@ struct Dog : virtual Animal {
Dog(const char* name, std::size_t type = static_type) : Animal(name, type) {
}
auto cast_aux(std::size_t type) -> void* override {
return type == static_type ? this : Animal::cast_aux(type);
auto cast_aux(std::size_t to_type) -> void* override {
return to_type == static_type ? this : Animal::cast_aux(to_type);
}
static constexpr std::size_t static_type = 1;
@@ -284,8 +284,8 @@ struct Cat : virtual Animal {
Cat(const char* name, std::size_t type = static_type) : Animal(name, type) {
}
auto cast_aux(std::size_t type) -> void* override {
return type == static_type ? this : Animal::cast_aux(type);
auto cast_aux(std::size_t to_type) -> void* override {
return to_type == static_type ? this : Animal::cast_aux(to_type);
}
static constexpr std::size_t static_type = 2;