[cfe-dev] shift-op-parantheses and multiplication

Daniel Marjamäki via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 20 08:23:31 PDT 2016


Hello!

I wonder what you think about making -Wshift-op-parantheses warn about multiplicative operators also.

It currently warns about this:

    a = (b + 1 << 2);

I suggest that it will warn about this also:

    a = (b * 1 << 2);

Possibly with a separate ID so that warning can be suppressed if you think it's obvious that multiplication is calculated first.

I attach a proof-of-concept patch.

Best regards,
Daniel Marjamäki

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 Daniel.Marjamaki at evidente.se

www.evidente.se
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 160920-shift-op-parentheses.diff
Type: text/x-patch
Size: 2410 bytes
Desc: 160920-shift-op-parentheses.diff
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160920/d9e4e2f3/attachment-0001.bin>


More information about the cfe-dev mailing list