]> granicus.if.org Git - clang/commit
Improve fix for PR28739
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jan 2017 02:23:02 +0000 (02:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jan 2017 02:23:02 +0000 (02:23 +0000)
commite7c5d7b74a14b8f013cd95ed493cce81571e6bc5
tree018bd1237f4d4dbb4af67650852dc373cad6bd2e
parentbaa8d90405a1ef158229648304c09cce0fa5d8e7
Improve fix for PR28739

Don't try to map an APSInt addend to an int64_t in pointer arithmetic before
bounds-checking it. This gives more consistent behavior (outside C++11, we
consistently use 2s complement semantics for both pointer and integer overflow
in constant expressions) and fixes some cases where in C++11 we would fail to
properly check for out-of-bounds pointer arithmetic (if the 2s complement
64-bit overflow landed us back in-bounds).

In passing, also fix some cases where we'd perform possibly-overflowing
arithmetic on CharUnits (which have a signed underlying type) during constant
expression evaluation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293595 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticASTKinds.td
lib/AST/ExprConstant.cpp
test/Sema/const-eval.c
test/SemaCXX/constant-expression-cxx11.cpp
test/SemaCXX/constant-expression-cxx1y.cpp