aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-06-14 08:57:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-06-14 08:57:18 +0000
commitc41c8b3a4a743fcf0998baea2c3b90434596010b (patch)
tree455402b45cffc12d216857da9aae36689f2f4cee /clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
parentef2ee4fec200c93e28c0f9bad7bbc39501d54901 (diff)
downloadllvm-c41c8b3a4a743fcf0998baea2c3b90434596010b.zip
llvm-c41c8b3a4a743fcf0998baea2c3b90434596010b.tar.gz
llvm-c41c8b3a4a743fcf0998baea2c3b90434596010b.tar.bz2
Fix the warning for divide by zero to be a bit more robust. ;]
Previously, it only ever fired for zeros which formed null pointers. Now, hilariously, in C++98 this was almost anything. Including tricks like warning on the divisor in this code: typedef char c3[3]; size_t f(c3* ptr) { return (sizeof(ptr) / sizeof(*ptr)) / (size_t)(!(sizeof(ptr) % sizeof(*ptr))); } Why the RHS of the outer divide is a null pointer constant is a sordid tale of sorrow. Anyways, the committee fixed this for C++11 and onward as part of core isssue 903, and Richard recently implemented this fix causing the warning to go away here (and elsewhere). This patch restores the warning here and adds it for numerous other somewhat obvious gaffes: int g(int x) { return x / (int)(0.0); } The patch is essentially just using the full power of our constant folding in Clang to produce the warning, but insisting that it must fold to an *integer* which is zero so that we don't get false positives anywhere. llvm-svn: 183970
Diffstat (limited to 'clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
0 files changed, 0 insertions, 0 deletions