diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-04-08 11:13:15 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-04-15 10:24:28 +0000 |
commit | b582d1422b4db6c22ff061a32257a83405d06cc9 (patch) | |
tree | 7de554bdd6e6e84bcb16d92a59069c0274bd8d8f | |
parent | 8d589e0cf9793996f24f0d6fa9fddbf8b2ce0cdd (diff) | |
download | src-b582d1422b4db6c22ff061a32257a83405d06cc9.tar.gz src-b582d1422b4db6c22ff061a32257a83405d06cc9.zip |
Avoid -pedantic warnings about using _Generic in __fp_type_select
When compiling parts of math.h with clang using a C standard before C11,
and using -pedantic, it will result in warnings similar to:
bug254714.c:5:11: warning: '_Generic' is a C11 extension [-Wc11-extensions]
return !isfinite(1.0);
^
/usr/include/math.h:111:21: note: expanded from macro 'isfinite'
^
/usr/include/math.h:82:39: note: expanded from macro '__fp_type_select'
^
This is because the block that enables use of _Generic is conditional
not only on C11, but also on whether the compiler advertises support for
C generic selections via __has_extension(c_generic_selections).
To work around the warning without having to pessimize the code, use the
__extension__ keyword, which is supported by both clang and gcc. While
here, remove the check for __clang__, as _Generic has been supported for
a long time by gcc too now.
Reported by: yuri
PR: 254714
-rw-r--r-- | lib/msun/src/math.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h index 6ce45cbb5280..2a42c14c6cc2 100644 --- a/lib/msun/src/math.h +++ b/lib/msun/src/math.h @@ -77,9 +77,8 @@ extern const union __nan_un { #define FP_SUBNORMAL 0x08 #define FP_ZERO 0x10 -#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \ - __has_extension(c_generic_selections) -#define __fp_type_select(x, f, d, ld) _Generic((x), \ +#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections) +#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \ float: f(x), \ double: d(x), \ long double: ld(x), \ |