Issue 91408
Summary [clang-tidy] clang-tidy 18.1.5 will issue error for switches on enums with or without default
Labels clang-tidy
Assignees
Reporter emosy
    Consider this file:
```
#include <_types/_uint32_t.h>
enum class test_enum : uint32_t {
  val1 = 0,
  val2 = 1
};

static test_enum getVal() {
  return test_enum::val1;
}

int main() {
    auto v = getVal();
    switch(v) {
        case test_enum::val1:
 return 1;
        case test_enum::val2:
            return 2;
 }

    return 0;
}
```

Run this file with clang-tidy 18.1.5 with `-checks=clang` and this error is reported:
`error: 'switch' missing 'default' label [clang-diagnostic-switch-default]`
but adding a default label will cause this error:
`error: default label in switch which covers all enumeration values [clang-diagnostic-covered-switch-default]`

It seems like you can't make clang-tidy happy either way.

Clang-tidy version: Homebrew LLVM version 18.1.5. Optimized build.
Platform: MacOS 14.1, Apple M3 Pro
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to