From c65d9ccdc2eccb0ccaf6efe00789f1bd4bdeba10 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Tue, 9 Jun 2020 10:53:21 +0000 Subject: [acinclude.m4] Make MPFR_CHECK_MP_LIMB_T_VS_LONG and MPFR_CHECK_MP_LIMB_T_VS_INTMAX similar: * Use AC_LINK_IFELSE in MPFR_CHECK_MP_LIMB_T_VS_LONG too: this is safer than AC_COMPILE_IFELSE, as it will detect undefined function-like macros. * Define MPFR_USE_STATIC_ASSERT in MPFR_CHECK_MP_LIMB_T_VS_INTMAX too in order to make sure that a static assertion is used (not the MPFR_ASSERTN fallback). Note: These constitute redundant safeguards because if MPFR_ASSERTN is used, it will be regarded as a function since the macro is not defined in this context, and linking will fail as a consequence. But this redundancy will protect more against MPFR code evolution. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13949 280ebfd0-de03-0410-8827-d642c229c3f4 --- acinclude.m4 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index aab0f49ee..5e58d476c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -996,7 +996,6 @@ esac dnl MPFR_CHECK_MP_LIMB_T_VS_LONG dnl ---------------------------- dnl Check whether a long fits in mp_limb_t. -dnl Note: Since AC_COMPILE_IFELSE is used, the test needs a static assertion. dnl If static assertions are not supported, one gets "no" even though a long dnl fits in mp_limb_t. Therefore, code without MPFR_LONG_WITHIN_LIMB defined dnl needs to be portable. @@ -1009,7 +1008,11 @@ AC_REQUIRE([MPFR_CONFIGS]) AC_CACHE_CHECK([for long to fit in mp_limb_t], mpfr_cv_long_within_limb, [ saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$srcdir/src" -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +dnl AC_LINK_IFELSE is safer than AC_COMPILE_IFELSE, as it will detect +dnl undefined function-like macros (which otherwise may be regarded +dnl as valid function calls with AC_COMPILE_IFELSE since prototypes +dnl are not required by the C standard). +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include /* Make sure that a static assertion is used (not MPFR_ASSERTN). */ #undef MPFR_USE_STATIC_ASSERT @@ -1037,10 +1040,15 @@ if test "$ac_cv_type_intmax_t" = yes; then AC_CACHE_CHECK([for intmax_t to fit in mp_limb_t], mpfr_cv_intmax_within_limb, [ saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$srcdir/src -DMPFR_NEED_INTMAX_H" -dnl AC_LINK_IFELSE is safier than AC_COMPILE_IFELSE, which did not detect -dnl the missing #include "mpfr-sassert.h". +dnl AC_LINK_IFELSE is safer than AC_COMPILE_IFELSE, as it will detect +dnl undefined function-like macros (which otherwise may be regarded +dnl as valid function calls with AC_COMPILE_IFELSE since prototypes +dnl are not required by the C standard). AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include +/* Make sure that a static assertion is used (not MPFR_ASSERTN). */ +#undef MPFR_USE_STATIC_ASSERT +#define MPFR_USE_STATIC_ASSERT 1 #include "mpfr-sassert.h" #include "mpfr-intmax.h" ]], [[ -- cgit v1.2.1