[Sema] Address-space sensitive index check for unbounded arrays
authorChris Hamilton <Chris.Hamilton@ericsson.com>
Mon, 14 Sep 2020 23:12:12 +0000 (18:12 -0500)
committerChris Hamilton <Chris.Hamilton@ericsson.com>
Mon, 14 Sep 2020 23:13:19 +0000 (18:13 -0500)
commitda55e9ba1273284f1af61bceeaeb25e487838034
tree422d87f8019702c7554773d14a3bda685ef8b709
parentf35617ad809b978635d10c0c39553840a03ac41f
[Sema] Address-space sensitive index check for unbounded arrays

Check applied to unbounded (incomplete) arrays and pointers
to spot cases where the computed address is beyond the
largest possible addressable extent of the array, based
on the address space in which the array is delcared, or
which the pointer refers to.

Check helps to avoid cases of nonsense pointer math and
array indexing which could lead to linker failures or
runtime exceptions.  Of particular interest when building
for embedded systems with small address spaces.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D86796
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/const-eval.c
clang/test/Sema/unbounded-array-bounds.c [new file with mode: 0644]
clang/test/SemaCXX/constant-expression-cxx1y.cpp