[clang] [Wunsafe-buffer-usage] Fix false positives in handling enums (PR #117370)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 20:48:17 PST 2024
================
@@ -39,6 +39,23 @@ void constant_idx_unsafe(unsigned idx) {
buffer[10] = 0; // expected-note{{used in buffer access here}}
}
+enum FooEnum {
+ A = 0,
+ B = 1,
+ C = 2,
+ D
+};
+
+void constant_enum_safe() {
+ int buffer[FooEnum::D] = { 0, 1, 2 };
+ buffer[C] = 0; // no-warning
----------------
mxms0 wrote:
Good suggestion, fixed :)
https://github.com/llvm/llvm-project/pull/117370
More information about the cfe-commits
mailing list