[gcc(refs/users/aoliva/heads/testme)] reject macros in math decl check

Alexandre Oliva aoliva@gcc.gnu.org
Wed Jan 22 02:08:00 GMT 2020


https://gcc.gnu.org/g:d8cde5806a180fb9e5c7dc3deecbec33cc55510e

commit d8cde5806a180fb9e5c7dc3deecbec33cc55510e
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Jan 21 19:58:03 2020 -0300

    reject macros in math decl check
    
    The C++ headers #undef the functions we are testing for, just in case
    they're implemented as macros.  Do that as well, so as to reject
    macros of the form #define foo bar, where bar is the actual
    implementation, since those wouldn't work in C++ after the #undef.
    
    While at that, tighten the test so that it doesn't take objects of
    pointer types as if they were functions.
    
    
    for  libstdc++-v3/ChangeLog
    
    	* crossconfig.m4 (GLIBCXX_CHECK_MATH_DECL): Reject macros and
    	data objects.
    	* configure: Rebuild.

Diff:
---
 libstdc++-v3/configure      | 66 ++++++++++++++++++++++++++++++---------------
 libstdc++-v3/crossconfig.m4 | 11 +++++++-
 2 files changed, 54 insertions(+), 23 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d2e516d..756ab2b2 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -72956,12 +72956,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef acosl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))acosl;
+  (void)(acosl - &acosl);
 
   ;
   return 0;
@@ -73006,12 +73007,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef asinl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))asinl;
+  (void)(asinl - &asinl);
 
   ;
   return 0;
@@ -73056,12 +73058,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef atan2l
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))atan2l;
+  (void)(atan2l - &atan2l);
 
   ;
   return 0;
@@ -73106,12 +73109,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef atanl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))atanl;
+  (void)(atanl - &atanl);
 
   ;
   return 0;
@@ -73156,12 +73160,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef ceill
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))ceill;
+  (void)(ceill - &ceill);
 
   ;
   return 0;
@@ -73206,12 +73211,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef cosl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))cosl;
+  (void)(cosl - &cosl);
 
   ;
   return 0;
@@ -73256,12 +73262,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef coshl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))coshl;
+  (void)(coshl - &coshl);
 
   ;
   return 0;
@@ -73306,12 +73313,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef expl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))expl;
+  (void)(expl - &expl);
 
   ;
   return 0;
@@ -73356,12 +73364,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef fabsl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))fabsl;
+  (void)(fabsl - &fabsl);
 
   ;
   return 0;
@@ -73406,12 +73415,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef floorl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))floorl;
+  (void)(floorl - &floorl);
 
   ;
   return 0;
@@ -73456,12 +73466,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef fmodl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))fmodl;
+  (void)(fmodl - &fmodl);
 
   ;
   return 0;
@@ -73506,12 +73517,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef frexpl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))frexpl;
+  (void)(frexpl - &frexpl);
 
   ;
   return 0;
@@ -73556,12 +73568,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef ldexpl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))ldexpl;
+  (void)(ldexpl - &ldexpl);
 
   ;
   return 0;
@@ -73606,12 +73619,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef log10l
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))log10l;
+  (void)(log10l - &log10l);
 
   ;
   return 0;
@@ -73656,12 +73670,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef logl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))logl;
+  (void)(logl - &logl);
 
   ;
   return 0;
@@ -73706,12 +73721,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef modfl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))modfl;
+  (void)(modfl - &modfl);
 
   ;
   return 0;
@@ -73756,12 +73772,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef powl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))powl;
+  (void)(powl - &powl);
 
   ;
   return 0;
@@ -73806,12 +73823,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef sinl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))sinl;
+  (void)(sinl - &sinl);
 
   ;
   return 0;
@@ -73856,12 +73874,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef sinhl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))sinhl;
+  (void)(sinhl - &sinhl);
 
   ;
   return 0;
@@ -73906,12 +73925,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef sqrtl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))sqrtl;
+  (void)(sqrtl - &sqrtl);
 
   ;
   return 0;
@@ -73956,12 +73976,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef tanl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))tanl;
+  (void)(tanl - &tanl);
 
   ;
   return 0;
@@ -74006,12 +74027,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef tanhl
 
 int
 main ()
 {
 
-  void (*f)(void) = (void (*)(void))tanhl;
+  (void)(tanhl - &tanhl);
 
   ;
   return 0;
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 2a0cb04..221b59d 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -322,6 +322,14 @@ dnl argument 1 is name of function to check
 dnl
 dnl ASSUMES argument is a math function
 dnl
+dnl Test for $1 - &$1: it's well-formed iff $1 names a function,
+dnl because $1's type decays to that of &$1.
+dnl For any object type, even arrays and void*, types won't match.
+dnl
+dnl Undefine $1, so that we don't accept an alias macro, e.g.
+dnl say define foo bar, when bar is the function.  Our C++ headers
+dnl undefine math function names, so such a macro wouldn't do.
+dnl
 dnl GLIBCXX_CHECK_MATH_DECL
 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL], [
   AC_CACHE_CHECK([for $1 declaration],
@@ -333,8 +341,9 @@ AC_DEFUN([GLIBCXX_CHECK_MATH_DECL], [
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #endif
+#undef $1
 ], [
-  void (*f)(void) = (void (*)(void))$1;
+  (void)($1 - &$1);
 ], [glibcxx_cv_func_$1_use=yes
 ], [glibcxx_cv_func_$1_use=no])])
   if test "x$glibcxx_cv_func_$1_use" = xyes; then



More information about the Libstdc++-cvs mailing list