[PATCH] D52137: Added warning for unary minus used with unsigned type
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 15 12:19:48 PDT 2018
rsmith added a comment.
I think we can and should do better about false positives here. If you move this check to SemaChecking, you can produce the warning in a context where you know what the final type is -- I don't think there's any reason to warn if the final type is signed and no wider than the promoted type of the negation.
I think we should also not warn when the negation is an operand of a & or | operator whose width is no greater than the promoted type of the negation, because -power_of_2 is an idiomatic way to form a mask.
https://reviews.llvm.org/D52137
More information about the cfe-commits
mailing list