Cleanup warnings with nvhpc/21.9. (#2582)

* Cleanup warnings with nvhpc/21.9.

* Move __NVCOMPILER check.

* Be more explicit.

* Immediately executed lambda.

* Fix shadowing warning.
This commit is contained in:
Olli Lupton 2021-11-05 20:17:11 +01:00 committed by GitHub
parent 812733cc96
commit e67f92c55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -24,7 +24,8 @@
# define FMT_CLANG_VERSION 0 # define FMT_CLANG_VERSION 0
#endif #endif
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
!defined(__NVCOMPILER)
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) # define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else #else
# define FMT_GCC_VERSION 0 # define FMT_GCC_VERSION 0

View File

@ -970,11 +970,14 @@ FMT_CONSTEXPR auto count_digits(UInt n) -> int {
if (num_bits<UInt>() == 32) if (num_bits<UInt>() == 32)
return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1; return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1;
#endif #endif
// Lambda avoids unreachable code warnings from NVHPC.
return [](UInt m) {
int num_digits = 0; int num_digits = 0;
do { do {
++num_digits; ++num_digits;
} while ((n >>= BITS) != 0); } while ((m >>= BITS) != 0);
return num_digits; return num_digits;
}(n);
} }
template <> auto count_digits<4>(detail::fallback_uintptr n) -> int; template <> auto count_digits<4>(detail::fallback_uintptr n) -> int;