diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-18 02:27:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-18 02:27:00 +0000 |
commit | 25b3b849e3ad340b04442707038c86980035765b (patch) | |
tree | cca95502a4a49dc69c0169eb954936b6289af129 /lib/Sema/SemaChecking.cpp | |
parent | 906c73ffbc78542ad333becb6e013dd9efc299b6 (diff) |
Fix assertion failure on -Warray-bounds for 32-bit builds of Clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 6b1013d82d..2cddac5f66 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3109,11 +3109,14 @@ void Sema::CheckArrayAccess(const clang::ArraySubscriptExpr *E) { return; if (!index.isNegative()) { - const llvm::APInt &size = ArrayTy->getSize(); + llvm::APInt size = ArrayTy->getSize(); if (!size.isStrictlyPositive()) return; if (size.getBitWidth() > index.getBitWidth()) index = index.sext(size.getBitWidth()); + else if (size.getBitWidth() < index.getBitWidth()) + size = size.sext(index.getBitWidth()); + if (index.slt(size)) return; |