[Sema] Address-space sensitive check for unbounded arrays (v2)
authorChris Hamilton <Chris.Hamilton@ericsson.com>
Tue, 29 Sep 2020 14:11:41 +0000 (16:11 +0200)
committerChris Hamilton <Chris.Hamilton@ericsson.com>
Tue, 29 Sep 2020 14:14:48 +0000 (16:14 +0200)
commitd9ee935679e7164d1c47e351bbbcf5c25742b59c
tree5551881e9be4d7ed58084428b3c84d5b31a91cec
parentdb04bec5f1eeb581ee1470e5f444cc7b918c6d93
[Sema] Address-space sensitive check for unbounded arrays (v2)

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.

This is version 2 of this patch -- version 1 had some testing issues
due to a sign error in existing code.  That error is corrected and
lit test for this chagne is extended to verify the fix.

Originally reviewed/accepted by: aaron.ballman
Original revision: https://reviews.llvm.org/D86796

Reviewed By: ebevhan

Differential Revision: https://reviews.llvm.org/D88174
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