Fix "unary minus operator applied to unsigned type, result still unsigned" on MSVC and other stupid warnings

This commit is contained in:
Charles Schlosser
2024-04-12 19:35:04 +00:00
committed by Rasmus Munk Larsen
parent dcdb0233c1
commit 122befe54c
15 changed files with 215 additions and 128 deletions

View File

@@ -9,21 +9,14 @@
#include "main.h"
// GCC<=4.8 has spurious shadow warnings, because `ptr` re-appears inside template instantiations
// workaround: put these in an anonymous namespace
namespace {
float* ptr;
const float* const_ptr;
} // namespace
template <typename PlainObjectType, bool IsDynamicSize = PlainObjectType::SizeAtCompileTime == Dynamic,
bool IsVector = PlainObjectType::IsVectorAtCompileTime>
struct mapstaticmethods_impl {};
template <typename PlainObjectType, bool IsVector>
struct mapstaticmethods_impl<PlainObjectType, false, IsVector> {
static void run(const PlainObjectType& m) {
mapstaticmethods_impl<PlainObjectType, true, IsVector>::run(m);
static void run(const PlainObjectType& m, float* ptr, const float* const_ptr) {
mapstaticmethods_impl<PlainObjectType, true, IsVector>::run(m, ptr, const_ptr);
int i = internal::random<int>(2, 5), j = internal::random<int>(2, 5);
@@ -66,7 +59,7 @@ struct mapstaticmethods_impl<PlainObjectType, false, IsVector> {
template <typename PlainObjectType>
struct mapstaticmethods_impl<PlainObjectType, true, false> {
static void run(const PlainObjectType& m) {
static void run(const PlainObjectType& m, float* ptr, const float* const_ptr) {
Index rows = m.rows(), cols = m.cols();
int i = internal::random<int>(2, 5), j = internal::random<int>(2, 5);
@@ -110,7 +103,7 @@ struct mapstaticmethods_impl<PlainObjectType, true, false> {
template <typename PlainObjectType>
struct mapstaticmethods_impl<PlainObjectType, true, true> {
static void run(const PlainObjectType& v) {
static void run(const PlainObjectType& v, float* ptr, const float* const_ptr) {
Index size = v.size();
int i = internal::random<int>(2, 5);
@@ -133,34 +126,34 @@ struct mapstaticmethods_impl<PlainObjectType, true, true> {
};
template <typename PlainObjectType>
void mapstaticmethods(const PlainObjectType& m) {
mapstaticmethods_impl<PlainObjectType>::run(m);
void mapstaticmethods(const PlainObjectType& m, float* ptr, const float* const_ptr) {
mapstaticmethods_impl<PlainObjectType>::run(m, ptr, const_ptr);
VERIFY(true); // just to avoid 'unused function' warning
}
EIGEN_DECLARE_TEST(mapstaticmethods) {
ptr = internal::aligned_new<float>(1000);
float* ptr = internal::aligned_new<float>(1000);
for (int i = 0; i < 1000; i++) ptr[i] = float(i);
const_ptr = ptr;
const float* const_ptr = ptr;
CALL_SUBTEST_1((mapstaticmethods(Matrix<float, 1, 1>())));
CALL_SUBTEST_1((mapstaticmethods(Vector2f())));
CALL_SUBTEST_2((mapstaticmethods(Vector3f())));
CALL_SUBTEST_2((mapstaticmethods(Matrix2f())));
CALL_SUBTEST_3((mapstaticmethods(Matrix4f())));
CALL_SUBTEST_3((mapstaticmethods(Array4f())));
CALL_SUBTEST_4((mapstaticmethods(Array3f())));
CALL_SUBTEST_4((mapstaticmethods(Array33f())));
CALL_SUBTEST_5((mapstaticmethods(Array44f())));
CALL_SUBTEST_5((mapstaticmethods(VectorXf(1))));
CALL_SUBTEST_5((mapstaticmethods(VectorXf(8))));
CALL_SUBTEST_6((mapstaticmethods(MatrixXf(1, 1))));
CALL_SUBTEST_6((mapstaticmethods(MatrixXf(5, 7))));
CALL_SUBTEST_7((mapstaticmethods(ArrayXf(1))));
CALL_SUBTEST_7((mapstaticmethods(ArrayXf(5))));
CALL_SUBTEST_8((mapstaticmethods(ArrayXXf(1, 1))));
CALL_SUBTEST_8((mapstaticmethods(ArrayXXf(8, 6))));
CALL_SUBTEST_1((mapstaticmethods(Matrix<float, 1, 1>(), ptr, const_ptr)));
CALL_SUBTEST_1((mapstaticmethods(Vector2f(), ptr, const_ptr)));
CALL_SUBTEST_2((mapstaticmethods(Vector3f(), ptr, const_ptr)));
CALL_SUBTEST_2((mapstaticmethods(Matrix2f(), ptr, const_ptr)));
CALL_SUBTEST_3((mapstaticmethods(Matrix4f(), ptr, const_ptr)));
CALL_SUBTEST_3((mapstaticmethods(Array4f(), ptr, const_ptr)));
CALL_SUBTEST_4((mapstaticmethods(Array3f(), ptr, const_ptr)));
CALL_SUBTEST_4((mapstaticmethods(Array33f(), ptr, const_ptr)));
CALL_SUBTEST_5((mapstaticmethods(Array44f(), ptr, const_ptr)));
CALL_SUBTEST_5((mapstaticmethods(VectorXf(1), ptr, const_ptr)));
CALL_SUBTEST_5((mapstaticmethods(VectorXf(8), ptr, const_ptr)));
CALL_SUBTEST_6((mapstaticmethods(MatrixXf(1, 1), ptr, const_ptr)));
CALL_SUBTEST_6((mapstaticmethods(MatrixXf(5, 7), ptr, const_ptr)));
CALL_SUBTEST_7((mapstaticmethods(ArrayXf(1), ptr, const_ptr)));
CALL_SUBTEST_7((mapstaticmethods(ArrayXf(5), ptr, const_ptr)));
CALL_SUBTEST_8((mapstaticmethods(ArrayXXf(1, 1), ptr, const_ptr)));
CALL_SUBTEST_8((mapstaticmethods(ArrayXXf(8, 6), ptr, const_ptr)));
internal::aligned_delete(ptr, 1000);
}