[PATCH] D123009: [Sema] Enum conversion warning when one signed and other unsigned.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 3 12:08:32 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/docs/ReleaseNotes.rst:113-114
by unary operators.
+- ``-Wenum-conversion`` now warns on conversion of signed enum to unsigned enum
+ and unsigned enum to signed enum rather than ``-Wsign-conversion``.
----------------
Minor tweak
================
Comment at: clang/test/Sema/enum-sign-conversion.c:6-8
+enum X { A,
+ B,
+ C };
----------------
Unrelated formatting change?
================
Comment at: clang/test/Sema/enum-sign-conversion.c:14-18
+enum SE1 { N1 = -1 };
+enum SE2 { N2 = -2 };
+// Unsigned unums
+enum UE1 { P1 };
+enum UE2 { P2 };
----------------
The second variants are unused.
================
Comment at: clang/test/Sema/enum-sign-conversion.c:37-43
+unsigned f5(enum UE1 E) {
+ return E; // signed-warning {{implicit conversion changes signedness: 'enum UE1' to 'unsigned int'}}
+}
+
+enum UE1 f6(unsigned E) {
+ return E; // signed-warning {{implicit conversion changes signedness: 'unsigned int' to 'enum UE1'}}
+}
----------------
Shouldn't these not warn as well -- the underlying enum type is unsigned?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123009/new/
https://reviews.llvm.org/D123009
More information about the cfe-commits
mailing list