A testdir shows compilation errors, when built with xlclang on AIX 7.2:

gmake[4]: Entering directory '/home/haible/testdir-all/build-32-xlclang/gltests'
depbase=`echo test-math-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
xlclang++ -qthreaded -qtls -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests 
-I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix32/include -D_THREAD_SAFE  -Wno-error -g -O2 -MT 
test-math-c++.o -MD -MP -MF $depbase.Tpo -c -o test-math-c++.o 
../../gltests/test-math-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:964:19: error: declaration of 'cbrtl' has a different language 
linkage
_GL_CXXALIASWARN (cbrtl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:721:20: note: previous definition is 
here
inline long double cbrtl(long double __x)               { return cbrt((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1077:19: error: declaration of 'copysignl' has a different 
language linkage
_GL_CXXALIASWARN (copysignl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:723:20: note: previous definition is 
here
inline long double copysignl(long double __x, long double __y)  { return 
copysign((double) (__x), (double) (__y)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1259:19: error: declaration of 'exp2l' has a different language 
linkage
_GL_CXXALIASWARN (exp2l);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:726:20: note: previous definition is 
here
inline long double exp2l(long double __x)               { return exp2((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1334:19: error: declaration of 'expm1l' has a different 
language linkage
_GL_CXXALIASWARN (expm1l);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:728:20: note: previous definition is 
here
inline long double expm1l(long double __x)              { return expm1((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1526:19: error: declaration of 'fmal' has a different language 
linkage
_GL_CXXALIASWARN (fmal);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:732:20: note: previous definition is 
here
inline long double fmal(long double __x, long double __y, long double __z)      
{ return fma((double) (__x), (double) (__y), (double) (__z)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1847:19: error: declaration of 'ilogbl' has a different 
language linkage
_GL_CXXALIASWARN (ilogbl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:1045:12: note: previous definition is 
here
inline int ilogbl(long double __x)              { return ilogb((double) (__x)); 
}
           ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2162:19: error: declaration of 'log1pl' has a different 
language linkage
_GL_CXXALIASWARN (log1pl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:741:20: note: previous definition is 
here
inline long double log1pl(long double __x)              { return log1p((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2236:19: error: declaration of 'log2l' has a different language 
linkage
_GL_CXXALIASWARN (log2l);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:742:20: note: previous definition is 
here
inline long double log2l(long double __x)               { return log2((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2308:19: error: declaration of 'logbl' has a different language 
linkage
_GL_CXXALIASWARN (logbl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:1046:20: note: previous definition is 
here
inline long double logbl(long double __x)               { return logb((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2474:19: error: declaration of 'remainderl' has a different 
language linkage
_GL_CXXALIASWARN (remainderl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:1048:20: note: previous definition is 
here
inline long double remainderl(long double __x, long double __y) { return 
remainder((double) (__x), (double) (__y)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2528:19: error: declaration of 'rintl' has a different language 
linkage
_GL_CXXALIASWARN (rintl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:1049:20: note: previous definition is 
here
inline long double rintl(long double __x)               { return rint((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2603:19: error: declaration of 'roundl' has a different 
language linkage
_GL_CXXALIASWARN (roundl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:751:20: note: previous definition is 
here
inline long double roundl(long double __x)              { return round((double) 
(__x)); }
                   ^
In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:2860:19: error: declaration of 'truncl' has a different 
language linkage
_GL_CXXALIASWARN (truncl);
                  ^
/opt/IBM/xlC/16.1.0/include2/aix/math.h:760:20: note: previous definition is 
here
inline long double truncl(long double __x)              { return trunc((double) 
(__x)); }
                   ^
../../gltests/test-math-c++.cc:395:4: warning: "isinf should not be a macro in 
C++" [-W#warnings]
#  warning "isinf should not be a macro in C++"
   ^
../../gltests/test-math-c++.cc:404:4: warning: "isnan should not be a macro in 
C++" [-W#warnings]
#  warning "isnan should not be a macro in C++"
   ^
2 warnings and 13 errors generated.
Error while processing ../../gltests/test-math-c++.cc.
Makefile:23408: recipe for target 'test-math-c++.o' failed
gmake[4]: *** [test-math-c++.o] Error 1

This patch fixes it.


2022-09-10  Bruno Haible  <br...@clisp.org>

        math: Fix compilation error in C++ mode on AIX 7.2 with xlclang.
        * lib/math.in.h (cbrtl, copysignl, exp2l, expm1l, fmal, ilogbl, log1pl,
        log2l, logbl, remainderl, rintl, roundl, truncl): Enable the C++ alias
        warning only on glibc systems.

diff --git a/lib/math.in.h b/lib/math.in.h
index 270e71f414..0ef1ba1028 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -454,7 +454,9 @@ _GL_FUNCDECL_SYS (cbrtl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (cbrtl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef cbrtl
 # if HAVE_RAW_DECL_CBRTL
@@ -567,7 +569,9 @@ _GL_WARN_ON_USE (copysign, "copysign is unportable - "
 _GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
 # endif
 _GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (copysignl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef copysignl
 # if HAVE_RAW_DECL_COPYSIGNL
@@ -749,7 +753,9 @@ _GL_FUNCDECL_SYS (exp2l, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (exp2l, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (exp2l);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef exp2l
 # if HAVE_RAW_DECL_EXP2L
@@ -824,7 +830,9 @@ _GL_FUNCDECL_SYS (expm1l, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (expm1l, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (expm1l);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef expm1l
 # if HAVE_RAW_DECL_EXPM1L
@@ -1016,7 +1024,9 @@ _GL_FUNCDECL_SYS (fmal, long double,
 _GL_CXXALIAS_SYS (fmal, long double,
                   (long double x, long double y, long double z));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fmal);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fmal
 # if HAVE_RAW_DECL_FMAL
@@ -1337,7 +1347,9 @@ _GL_FUNCDECL_SYS (ilogbl, int, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (ilogbl, int, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ilogbl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef ilogbl
 # if HAVE_RAW_DECL_ILOGBL
@@ -1652,7 +1664,9 @@ _GL_FUNCDECL_SYS (log1pl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (log1pl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (log1pl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef log1pl
 # if HAVE_RAW_DECL_LOG1PL
@@ -1726,7 +1740,9 @@ _GL_FUNCDECL_SYS (log2l, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (log2l, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (log2l);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef log2l
 # if HAVE_RAW_DECL_LOG2L
@@ -1798,7 +1814,9 @@ _GL_FUNCDECL_SYS (logbl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (logbl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (logbl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef logbl
 # if HAVE_RAW_DECL_LOGBL
@@ -1964,7 +1982,9 @@ _GL_FUNCDECL_SYS (remainderl, long double, (long double 
x, long double y));
 #  endif
 _GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (remainderl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef remainderl
 # if HAVE_RAW_DECL_REMAINDERL
@@ -2018,7 +2038,9 @@ _GL_FUNCDECL_SYS (rintl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (rintl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (rintl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef rintl
 # if HAVE_RAW_DECL_RINTL
@@ -2093,7 +2115,9 @@ _GL_FUNCDECL_SYS (roundl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (roundl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (roundl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef roundl
 # if HAVE_RAW_DECL_ROUNDL
@@ -2350,7 +2374,9 @@ _GL_FUNCDECL_SYS (truncl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (truncl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (truncl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef truncl
 # if HAVE_RAW_DECL_TRUNCL




Reply via email to