From 83de1770aa5ca77be62d797fa477506fb97c7cc8 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Sat, 6 Mar 2021 12:51:51 +0000 Subject: [tests] In C++, do not cast to "void *" in the tests of macros. These casts make the build of these tests fail with a C++ compiler. But this means that the use of macros will not introduce any issue concerning the type of the arguments, i.e. with a C++ compiler, the tests are still complete after this change. However, GCC's -Werror=c++-compat still cannot be used. git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14460 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/mpfr-test.h | 6 ++++++ tests/tcopysign.c | 12 ++++++------ tests/tisnan.c | 2 +- tests/tset.c | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h index 0466903d3..79c5ad6c7 100644 --- a/tests/mpfr-test.h +++ b/tests/mpfr-test.h @@ -92,6 +92,12 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define STRINGIZE(S) #S #define MAKE_STR(S) STRINGIZE(S) +#if defined (__cplusplus) +#define VOIDP_CAST(X) (X) +#else +#define VOIDP_CAST(X) ((void *) (X)) +#endif + #if defined (__cplusplus) extern "C" { #endif diff --git a/tests/tcopysign.c b/tests/tcopysign.c index a96250381..c83b3d3d6 100644 --- a/tests/tcopysign.c +++ b/tests/tcopysign.c @@ -52,9 +52,9 @@ copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, (mpfr_copysign) (z, p, y, rnd_mode); return; case 2: - mpfr_copysign ((a++, (void *) z), - (b++, (void *) p), - (c++, (void *) y), rnd_mode); + mpfr_copysign ((a++, VOIDP_CAST(z)), + (b++, VOIDP_CAST(p)), + (c++, VOIDP_CAST(y)), rnd_mode); MPFR_ASSERTN (a == 1); MPFR_ASSERTN (b == 1); MPFR_ASSERTN (c == 1); @@ -72,9 +72,9 @@ copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, (mpfr_setsign) (z, p, (mpfr_signbit) (y), rnd_mode); return; case 7: - mpfr_setsign ((a++, (void *) z), - (b++, (void *) p), - mpfr_signbit ((c++, (void *) y)), rnd_mode); + mpfr_setsign ((a++, VOIDP_CAST(z)), + (b++, VOIDP_CAST(p)), + mpfr_signbit ((c++, VOIDP_CAST(y))), rnd_mode); MPFR_ASSERTN (a == 1); MPFR_ASSERTN (b == 1); MPFR_ASSERTN (c == 1); diff --git a/tests/tisnan.c b/tests/tisnan.c index 83748f530..9e234b8d1 100644 --- a/tests/tisnan.c +++ b/tests/tisnan.c @@ -31,7 +31,7 @@ main (void) /* We need to check that when the function is implemented by a macro, it behaves correctly. */ -#define ARG (i++, (void *) x) +#define ARG (i++, VOIDP_CAST(x)) #define CHECK MPFR_ASSERTN (i == ++j) tests_start_mpfr (); diff --git a/tests/tset.c b/tests/tset.c index e820e2df5..2683425e1 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -239,8 +239,8 @@ check_ternary_value (void) inexact = (mpfr_set) (y, x, (mpfr_rnd_t) rnd); break; case 2: - inexact = mpfr_set ((a++, (void *) y), - (b++, (void *) x), + inexact = mpfr_set ((a++, VOIDP_CAST(y)), + (b++, VOIDP_CAST(x)), (c++, (mpfr_rnd_t) rnd)); MPFR_ASSERTN (a == 1); MPFR_ASSERTN (b == 1); -- cgit v1.2.1