silencing -Wc++20-extensions at the point of use solely

This commit is contained in:
Daniel Lemire 2026-06-07 11:18:09 -04:00
parent 520fded4a3
commit b1fbfe932a
2 changed files with 8 additions and 12 deletions

View File

@ -212,18 +212,7 @@ using parse_options = parse_options_t<char>;
#endif
#ifdef FASTFLOAT_USE_UNLIKELY_ATTR
// We have to disable -Wc++20-extensions for the [[unlikely]] attribute
// See comment for @jwakely at
// https://github.com/fastfloat/fast_float/pull/387#discussion_r3366943539
// This is unfortunate.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++20-extensions"
#endif
#define fastfloat_unlikely(x) (x) [[unlikely]]
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#elif defined(__GNUC__) || defined(__clang__)
#define fastfloat_unlikely(x) (__builtin_expect(!!(x), 0))
#else

View File

@ -351,6 +351,11 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
// Slow path A (rare): > 19 significant digits. The no-span parse left the
// mantissa un-truncated and skipped the span-based recompute; the cold helper
// re-parses with spans and runs the full algorithm.
//
// We have to disable -Wc++20-extensions for the [[unlikely]] attribute
// See comment for @jwakely at
// https://github.com/fastfloat/fast_float/pull/387#discussion_r3366943539
// This is unfortunate.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++20-extensions"
@ -358,7 +363,9 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
if fastfloat_unlikely (pns.too_many_digits) {
return parse_number_slow_path<T, UC>(first, last, value, options, bjf);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
answer.ec = std::errc(); // be optimistic
answer.ptr = pns.lastmatch;