https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108811
Bug ID: 108811
Summary: add enum annotation for switch statements
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tromey at gcc dot gnu.org
Target Milestone: ---
In gdb we don't generally want -Wswitch-enum, because there are many
switches where it's not appropriate. However, for a subset of switch
statements, it is nice to have -- it means we can make them "future
proof" against things like adding a new type code.
Right now we can do this by pushing and popping diagnostics.
However, this relies on remembering to surround the switch with
some macros.
It would be nice, instead, to have an attribute we could apply to the
switch statement itself. Then we'd only have to mark a single spot,
like:
[[gnu::switch_enum]] switch (...)