From 69c0a24af61755402c965be76abde59fa2fbe805 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Sat, 14 Oct 2017 13:54:23 +0900 Subject: [PATCH] fix(Clang CodeGen): remove warnings ./fmt/fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas] # pragma intrinsic(_BitScanReverse) ^ 1 warning generated. format.cc In file included from fmt\fmt\format.cc:28: fmt\fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas] # pragma intrinsic(_BitScanReverse) ^ fmt\fmt\format.cc(165,17): warning : 'strerror' is deprecated: This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] buffer_ = strerror(error_code_); ^ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(178,24) : note: 'strerror' has been explicitly marked deprecated here _ACRTIMP char* __cdecl strerror( ^ fmt\fmt\format.cc(78,37): warning : unused function 'strerror_s' [-Wunused-function] static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) { ^ 3 warnings generated. --- fmt/format.cc | 18 ++++++++++++++++++ fmt/format.h | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fmt/format.cc b/fmt/format.cc index 4b7c2d24..4c14d0c6 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -70,6 +70,11 @@ # pragma warning(disable: 4996) #endif +#ifdef __c2__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-function" +#endif + // Dummy implementations of strerror_r and strerror_s called if corresponding // system functions are not available. static inline fmt::internal::Null<> strerror_r(int, char *, ...) { @@ -79,6 +84,10 @@ static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) { return fmt::internal::Null<>(); } +#ifdef __c2__ +# pragma clang diagnostic pop +#endif + namespace fmt { FMT_FUNC internal::RuntimeError::~RuntimeError() FMT_DTOR_NOEXCEPT {} @@ -159,6 +168,11 @@ int safe_strerror( ERANGE : result; } +#ifdef __c2__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + // Fallback to strerror if strerror_r and strerror_s are not available. int fallback(internal::Null<>) { errno = 0; @@ -166,6 +180,10 @@ int safe_strerror( return errno; } +#ifdef __c2__ +# pragma clang diagnostic pop +#endif + public: StrError(int err_code, char *&buf, std::size_t buf_size) : error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {} diff --git a/fmt/format.h b/fmt/format.h index c02a301e..c91bbf60 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -335,7 +335,10 @@ typedef __int64 intmax_t; namespace fmt { namespace internal { -# pragma intrinsic(_BitScanReverse) +// avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning +# ifndef __clang__ +# pragma intrinsic(_BitScanReverse) +# endif inline uint32_t clz(uint32_t x) { unsigned long r = 0; _BitScanReverse(&r, x); @@ -349,7 +352,8 @@ inline uint32_t clz(uint32_t x) { } # define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n) -# ifdef _WIN64 +// avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning +# if defined(_WIN64) && !defined(__clang__) # pragma intrinsic(_BitScanReverse64) # endif