]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Avoid -pedantic warnings about using _Generic in __fp_type_select
authorDimitry Andric <dim@FreeBSD.org>
Thu, 8 Apr 2021 11:13:15 +0000 (13:13 +0200)
committerDimitry Andric <dim@FreeBSD.org>
Thu, 8 Apr 2021 16:20:32 +0000 (18:20 +0200)
commit7702d940ec9a27fd4ab9e3991fc582b369b5eedc
tree243c01fa6c3a86e0f50adfc64e1bfa8753fcbba5
parentf2ecc0d1b7d569b4b2c930c7450390c04778ee8a
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
MFC after: 1 week
lib/msun/src/math.h