Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all clang -Wsigned-enum-bitfield warnings #2882

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2029,14 +2029,23 @@ template <typename Context> class basic_format_args {
// between clang and gcc on ARM (#1919).
using format_args = basic_format_args<format_context>;

// We cannot use enum classes as bit fields because of a gcc bug
// We cannot use enum classes as bit fields because of a gcc bug,
// so we put them in namespaces instead.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414.
// Additionally, if an underlying type is specified, older gcc incorrectly warns
// that the type is too small for all the enum values.
// Both these bugs are fixed as of gcc 9.3.
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 903
# define FMT_ENUM_UNDERLYING_TYPE(type)
#else
# define FMT_ENUM_UNDERLYING_TYPE(type) : type
#endif
namespace align {
enum type { none, left, right, center, numeric };
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) { none, left, right, center, numeric };
}
using align_t = align::type;
namespace sign {
enum type { none, minus, plus, space };
enum type FMT_ENUM_UNDERLYING_TYPE(unsigned char) { none, minus, plus, space };
}
using sign_t = sign::type;

Expand Down