[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 21 12:27:13 PDT 2017
efriedma added inline comments.
================
Comment at: lib/Sema/SemaChecking.cpp:8176
+ // underlying type, so that when someone specifies the type as
+ // "unsigned" it doesn't cause sign-conversion type warnings.
if (!Enum->isCompleteDefinition())
----------------
Explicitly referencing sign-conversion warnings here isn't really helpful. Maybe something more like "Incomplete enums without definitions can have an explicitly specified underlying type. Use that type here to compute the range."
================
Comment at: test/SemaCXX/warn-sign-conversion-cpp11.cpp:11
+ // For a non-defined enum, use the underlying type.
+ enum u8 : char;
+ u8 foo{static_cast<u8>(0)};
----------------
The signedness of "char" can vary based on the host; probably simplest to write out "signed char".
https://reviews.llvm.org/D38145
More information about the cfe-commits
mailing list