[all-commits] [llvm/llvm-project] 832259: PR51158: Don't emit -Wswitch or -Wcovered-switch-d...
David Blaikie via All-commits
all-commits at lists.llvm.org
Thu Jul 22 14:52:23 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 83225936af317e6bdd7103a8a039c51a29ce9f57
https://github.com/llvm/llvm-project/commit/83225936af317e6bdd7103a8a039c51a29ce9f57
Author: David Blaikie <dblaikie at gmail.com>
Date: 2021-07-22 (Thu, 22 Jul 2021)
Changed paths:
M clang/lib/Sema/SemaStmt.cpp
M clang/test/SemaCXX/switch.cpp
Log Message:
-----------
PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums
An empty enum is used to implement C++'s new-ish "byte" type (to make
sure it's a separate type for overloading, etc - compared to a typedef)
- without any enumerators. Some clang warnings don't make sense in this
sort of situation, so let's skip them for empty enums.
It's arguable that possibly some situations of enumerations without
enumerators might want the previous-to-this-patch behavior (if the enum
is autogenerated and in some cases comes up empty, then maybe a default
in an empty switch would still be considered problematic - so that when
you add the first enumeration you do get a -Wswitch warning). But I
think that's niche enough & this std::byte case is mainstream enough
that we should prioritize the latter over the former.
If someone's got a middle ground proposal to account for both of those
situations, I'm open to patches/suggestions/etc.
More information about the All-commits
mailing list