Introduce a TEST_SET_BUT_UNUSED_VARIABLE macro for initialized but unused variables in the unit tests and also fix a few other warnings.

This commit is contained in:
Gael Guennebaud 2013-06-25 11:42:04 +02:00
parent 4cc9377941
commit 95f8a738ea
17 changed files with 29 additions and 36 deletions

View File

@ -851,7 +851,6 @@ struct solve_retval<JacobiSVD<_MatrixType, QRPreconditioner>, Rhs>
// So A^{-1} = V S^{-1} U^* // So A^{-1} = V S^{-1} U^*
Matrix<Scalar, Dynamic, Rhs::ColsAtCompileTime, 0, _MatrixType::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime> tmp; Matrix<Scalar, Dynamic, Rhs::ColsAtCompileTime, 0, _MatrixType::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime> tmp;
Index diagSize = (std::min)(dec().rows(), dec().cols());
Index nonzeroSingVals = dec().nonzeroSingularValues(); Index nonzeroSingVals = dec().nonzeroSingularValues();
tmp.noalias() = dec().matrixU().leftCols(nonzeroSingVals).adjoint() * rhs(); tmp.noalias() = dec().matrixU().leftCols(nonzeroSingVals).adjoint() * rhs();

View File

@ -305,7 +305,6 @@ template<typename MatrixType> void cholesky_verify_assert()
void test_cholesky() void test_cholesky()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) ); CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) );
CALL_SUBTEST_3( cholesky(Matrix2d()) ); CALL_SUBTEST_3( cholesky(Matrix2d()) );
@ -328,5 +327,5 @@ void test_cholesky()
CALL_SUBTEST_9( LLT<MatrixXf>(10) ); CALL_SUBTEST_9( LLT<MatrixXf>(10) );
CALL_SUBTEST_9( LDLT<MatrixXf>(10) ); CALL_SUBTEST_9( LDLT<MatrixXf>(10) );
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -55,7 +55,6 @@ void test_determinant()
{ {
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) ); CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) ); CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
@ -63,6 +62,6 @@ void test_determinant()
CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) ); CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
CALL_SUBTEST_6( determinant(MatrixXd(s, s)) ); CALL_SUBTEST_6( determinant(MatrixXd(s, s)) );
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }
} }

View File

@ -102,7 +102,6 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
void test_eigensolver_complex() void test_eigensolver_complex()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( eigensolver(Matrix4cf()) ); CALL_SUBTEST_1( eigensolver(Matrix4cf()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
@ -119,5 +118,5 @@ void test_eigensolver_complex()
// Test problem size constructors // Test problem size constructors
CALL_SUBTEST_5(ComplexEigenSolver<MatrixXf> tmp(s)); CALL_SUBTEST_5(ComplexEigenSolver<MatrixXf> tmp(s));
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -45,7 +45,6 @@ void test_eigensolver_generalized_real()
{ {
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
CALL_SUBTEST_1( generalized_eigensolver_real(Matrix4f()) ); CALL_SUBTEST_1( generalized_eigensolver_real(Matrix4f()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(s,s)) ); CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(s,s)) );
@ -55,6 +54,6 @@ void test_eigensolver_generalized_real()
CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(2,2)) ); CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(2,2)) );
CALL_SUBTEST_3( generalized_eigensolver_real(Matrix<double,1,1>()) ); CALL_SUBTEST_3( generalized_eigensolver_real(Matrix<double,1,1>()) );
CALL_SUBTEST_4( generalized_eigensolver_real(Matrix2d()) ); CALL_SUBTEST_4( generalized_eigensolver_real(Matrix2d()) );
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }
} }

View File

@ -89,7 +89,6 @@ template<typename MatrixType> void eigensolver_verify_assert(const MatrixType& m
void test_eigensolver_generic() void test_eigensolver_generic()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( eigensolver(Matrix4f()) ); CALL_SUBTEST_1( eigensolver(Matrix4f()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
@ -122,5 +121,5 @@ void test_eigensolver_generic()
} }
); );
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -111,7 +111,6 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
void test_eigensolver_selfadjoint() void test_eigensolver_selfadjoint()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
// very important to test 3x3 and 2x2 matrices since we provide special paths for them // very important to test 3x3 and 2x2 matrices since we provide special paths for them
CALL_SUBTEST_1( selfadjointeigensolver(Matrix2d()) ); CALL_SUBTEST_1( selfadjointeigensolver(Matrix2d()) );
@ -139,6 +138,6 @@ void test_eigensolver_selfadjoint()
CALL_SUBTEST_8(SelfAdjointEigenSolver<MatrixXf> tmp1(s)); CALL_SUBTEST_8(SelfAdjointEigenSolver<MatrixXf> tmp1(s));
CALL_SUBTEST_8(Tridiagonalization<MatrixXf> tmp2(s)); CALL_SUBTEST_8(Tridiagonalization<MatrixXf> tmp2(s));
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -87,7 +87,6 @@ template<typename MatrixType> void inverse(const MatrixType& m)
void test_inverse() void test_inverse()
{ {
int s = 0; int s = 0;
s = s; // ICC shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) ); CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) );
CALL_SUBTEST_2( inverse(Matrix2d()) ); CALL_SUBTEST_2( inverse(Matrix2d()) );
@ -101,5 +100,5 @@ void test_inverse()
CALL_SUBTEST_7( inverse(Matrix4d()) ); CALL_SUBTEST_7( inverse(Matrix4d()) );
CALL_SUBTEST_7( inverse(Matrix<double,4,4,DontAlign>()) ); CALL_SUBTEST_7( inverse(Matrix<double,4,4,DontAlign>()) );
} }
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -324,8 +324,10 @@ void test_jacobisvd()
int r = internal::random<int>(1, 30), int r = internal::random<int>(1, 30),
c = internal::random<int>(1, 30); c = internal::random<int>(1, 30);
r = r; // shuts down ICC's remark #593: variable "s" was set but never used
c = c; TEST_SET_BUT_UNUSED_VARIABLE(r)
TEST_SET_BUT_UNUSED_VARIABLE(c)
CALL_SUBTEST_7(( jacobisvd<MatrixXf>(MatrixXf(r,c)) )); CALL_SUBTEST_7(( jacobisvd<MatrixXf>(MatrixXf(r,c)) ));
CALL_SUBTEST_8(( jacobisvd<MatrixXcd>(MatrixXcd(r,c)) )); CALL_SUBTEST_8(( jacobisvd<MatrixXcd>(MatrixXcd(r,c)) ));
(void) r; (void) r;

View File

@ -31,6 +31,10 @@
// B0 is defined in POSIX header termios.h // B0 is defined in POSIX header termios.h
#define B0 FORBIDDEN_IDENTIFIER #define B0 FORBIDDEN_IDENTIFIER
// shuts down ICC's remark #593: variable "XXX" was set but never used
#define TEST_SET_BUT_UNUSED_VARIABLE(X) X = X + 0;
// the following file is automatically generated by cmake // the following file is automatically generated by cmake
#include "split_test_helper.h" #include "split_test_helper.h"

View File

@ -63,7 +63,6 @@ template<typename MatrixType> void product_selfadjoint(const MatrixType& m)
void test_product_selfadjoint() void test_product_selfadjoint()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat ; i++) { for(int i = 0; i < g_repeat ; i++) {
CALL_SUBTEST_1( product_selfadjoint(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( product_selfadjoint(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( product_selfadjoint(Matrix<float, 2, 2>()) ); CALL_SUBTEST_2( product_selfadjoint(Matrix<float, 2, 2>()) );
@ -77,5 +76,5 @@ void test_product_selfadjoint()
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);
CALL_SUBTEST_7( product_selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s,s)) ); CALL_SUBTEST_7( product_selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s,s)) );
} }
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -74,7 +74,6 @@ template<typename MatrixType> void trmv(const MatrixType& m)
void test_product_trmv() void test_product_trmv()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat ; i++) { for(int i = 0; i < g_repeat ; i++) {
CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( trmv(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) ); CALL_SUBTEST_2( trmv(Matrix<float, 2, 2>()) );
@ -86,5 +85,5 @@ void test_product_trmv()
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);
CALL_SUBTEST_6( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) ); CALL_SUBTEST_6( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) );
} }
EIGEN_UNUSED_VARIABLE(s); TEST_SET_BUT_UNUSED_VARIABLE(s);
} }

View File

@ -49,7 +49,6 @@ template<typename MatrixType> void real_qz(const MatrixType& m)
void test_real_qz() void test_real_qz()
{ {
int s = 0; int s = 0;
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( real_qz(Matrix4f()) ); CALL_SUBTEST_1( real_qz(Matrix4f()) );
s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4); s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE/4);
@ -62,5 +61,5 @@ void test_real_qz()
CALL_SUBTEST_4( real_qz(Matrix2d()) ); CALL_SUBTEST_4( real_qz(Matrix2d()) );
} }
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }

View File

@ -133,8 +133,7 @@ void test_redux()
{ {
// the max size cannot be too large, otherwise reduxion operations obviously generate large errors. // the max size cannot be too large, otherwise reduxion operations obviously generate large errors.
int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE); int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE);
maxsize = maxsize; // shuts down ICC's remark #593: variable "s" was set but never used TEST_SET_BUT_UNUSED_VARIABLE(maxsize);
EIGEN_UNUSED_VARIABLE(maxsize);
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) );
CALL_SUBTEST_1( matrixRedux(Array<float, 1, 1>()) ); CALL_SUBTEST_1( matrixRedux(Array<float, 1, 1>()) );

View File

@ -47,7 +47,6 @@ void test_selfadjoint()
for(int i = 0; i < g_repeat ; i++) for(int i = 0; i < g_repeat ; i++)
{ {
int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE); int s = internal::random<int>(1,EIGEN_TEST_MAX_SIZE);
s = s; // shuts down ICC's remark #593: variable "s" was set but never used
CALL_SUBTEST_1( selfadjoint(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( selfadjoint(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( selfadjoint(Matrix<float, 2, 2>()) ); CALL_SUBTEST_2( selfadjoint(Matrix<float, 2, 2>()) );
@ -55,7 +54,7 @@ void test_selfadjoint()
CALL_SUBTEST_4( selfadjoint(MatrixXcd(s,s)) ); CALL_SUBTEST_4( selfadjoint(MatrixXcd(s,s)) );
CALL_SUBTEST_5( selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) ); CALL_SUBTEST_5( selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) );
EIGEN_UNUSED_VARIABLE(s) TEST_SET_BUT_UNUSED_VARIABLE(s)
} }
CALL_SUBTEST_1( bug_159() ); CALL_SUBTEST_1( bug_159() );

View File

@ -211,8 +211,8 @@ void test_triangular()
int maxsize = (std::min)(EIGEN_TEST_MAX_SIZE,20); int maxsize = (std::min)(EIGEN_TEST_MAX_SIZE,20);
for(int i = 0; i < g_repeat ; i++) for(int i = 0; i < g_repeat ; i++)
{ {
int r = internal::random<int>(2,maxsize); r=r; // shuts down ICC's remark #593: variable "s" was set but never used int r = internal::random<int>(2,maxsize); TEST_SET_BUT_UNUSED_VARIABLE(r)
int c = internal::random<int>(2,maxsize); c=c; int c = internal::random<int>(2,maxsize); TEST_SET_BUT_UNUSED_VARIABLE(c)
CALL_SUBTEST_1( triangular_square(Matrix<float, 1, 1>()) ); CALL_SUBTEST_1( triangular_square(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( triangular_square(Matrix<float, 2, 2>()) ); CALL_SUBTEST_2( triangular_square(Matrix<float, 2, 2>()) );