From 5379063b54f10f1052cd436b8aa0830ec4d21edb Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 7 Mar 2022 11:16:43 -0500 Subject: [PATCH] Fixed clang -Wreserved-identifier warings Created FMT_UNCHECKED_TYPE that resolves to special identifier _Unchecked_type for Microsoft, but to a dummy string otherwise. Using _Unchecked_type is invalid because underscore + uppercase is a reserved identifier. --- include/fmt/compile.h | 3 +-- include/fmt/core.h | 9 ++++++++- include/fmt/format.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/fmt/compile.h b/include/fmt/compile.h index b2bf1ba10465..296ef42c697d 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -36,8 +36,7 @@ template class truncating_iterator_base { using difference_type = std::ptrdiff_t; using pointer = void; using reference = void; - using _Unchecked_type = - truncating_iterator_base; // Mark iterator as checked. + FMT_UNCHECKED_ITERATOR(truncating_iterator_base); OutputIt base() const { return out_; } size_t count() const { return count_; } diff --git a/include/fmt/core.h b/include/fmt/core.h index 106fd6fe8760..3feb2a7dc81e 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -217,6 +217,13 @@ # endif #endif +#ifdef _MSC_VER +# define FMT_UNCHECKED_ITERATOR(It) \ + using _Unchecked_type = It // Mark iterator as checked. +#else +# define FMT_UNCHECKED_ITERATOR(It) using DummyTypeName = It +#endif + #ifndef FMT_BEGIN_NAMESPACE # define FMT_BEGIN_NAMESPACE \ namespace fmt { \ @@ -1498,7 +1505,7 @@ class appender : public std::back_insert_iterator> { public: using std::back_insert_iterator>::back_insert_iterator; appender(base it) noexcept : base(it) {} - using _Unchecked_type = appender; // Mark iterator as checked. + FMT_UNCHECKED_ITERATOR(appender); auto operator++() noexcept -> appender& { return *this; } diff --git a/include/fmt/format.h b/include/fmt/format.h index 57fc059c2456..67e5bcca44f8 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1968,7 +1968,7 @@ class counting_iterator { using difference_type = std::ptrdiff_t; using pointer = void; using reference = void; - using _Unchecked_type = counting_iterator; // Mark iterator as checked. + FMT_UNCHECKED_ITERATOR(counting_iterator); struct value_type { template void operator=(const T&) {}