summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.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
commit93f32da079874f70857af42eb9be382f307d4f1e (patch)
tree2ae1f8f0161a1eb00a787063b5afec61b73f1fa6 /lib/CodeGen/CodeGenFunction.cpp
parent3282b84296dba58e811741b63e4429980a98df8b (diff)
downloadclang-93f32da079874f70857af42eb9be382f307d4f1e.tar.gz
clang-93f32da079874f70857af42eb9be382f307d4f1e.tar.bz2
clang-93f32da079874f70857af42eb9be382f307d4f1e.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions