[cfe-dev] RFC redundant assignment in switch

Jordan Rose jordan_rose at apple.com
Mon Mar 31 09:08:29 PDT 2014


On Mar 30, 2014, at 19:47 , Kyle Sluder <kyle at ksluder.com> wrote:

> On Mar 28, 2014, at 1:52 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>> 
>> Hi, Daniel. We already have this in Clang itself as -Wimplicit-fallthrough,
> 
> That warning triggers for every fallthrough. Daniel’s checker only triggers for assignments that are redundant with assignments made in cases that are fallen into.
> 
> These are philosophically different approaches, and they are mutually compatible. Even if -Wimplicit-fallthrough becomes useful to C/ObjC programmers via the __fallthrough macro, Daniel’s checker is still useful because it will catch logic bugs in code that redundantly assigns to the same variable in two different cases.

Ah, interesting. Isn't this already caught with the dead stores checker, though?

<stdin>:5:5: warning: Value stored to 'y' is never read
    y = 1;
    ^   ~

We could probably stand to improve that checker to say why something's a dead store, but I don't think we need a separate pass.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140331/57934fd5/attachment.html>


More information about the cfe-dev mailing list