[cfe-dev] Overeager -Wswitch

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 11 11:59:27 PDT 2015


On Sun, Oct 11, 2015 at 07:58:32PM +0200, Kim Gräsman wrote:
> Hi Joerg,
> 
> On Sat, Oct 10, 2015 at 1:33 PM, Joerg Sonnenberger via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
> > On Sat, Oct 10, 2015 at 10:21:17AM +0200, Kim Gräsman via cfe-dev wrote:
> >> Alternatively, if we could get a patch into Poco, is there something
> >> like MSVC's #pragma(warning:disable) for Clang, so they could
> >> selectively silence the warning around this function?
> >
> > add GCC diagnostic push
> > #pragma GCC diagnostic ignored "-Wswitch"
> > ... your function here...
> > #pragma GCC diagnostic pop
> >
> > I think it also works with clang as pragma group.
> 
> Thanks, that's what I was looking for in the way of disabling. To
> confirm, #pragma clang diagnostic also works.
> 
> I think we've agreed to rewrite the function in Poco using if/else
> instead of switch, because it was hard to find a switch phrasing that
> worked with all -W combinations (-Weverything overrode the #pragma
> diagnostic and threw diagnostics for code that worked with -Wall).
> 
> That said, it might be worth trying to make Clang aware of libstdc++'s
> enum convention, but I haven't thought of a way to do so yet.

I don't think there is anything Clang can or should do here, but please
fill an upstream report against GCC if they still do it in the most
recent version.

Joerg



More information about the cfe-dev mailing list