[Sema] Reject array element types whose sizes aren't a multiple of their
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 25 Jun 2022 20:19:52 +0000 (13:19 -0700)
committerAkira Hatanaka <ahatanaka@apple.com>
Wed, 21 Sep 2022 16:15:03 +0000 (09:15 -0700)
commitadaf62ced2a106b9f16974f09ef6294583637288
treec066c2a6e0f7ff8d15e44254abf39cc46b5e1b7e
parentf47a5df92d488bdff418e3b1d249f407885896f2
[Sema] Reject array element types whose sizes aren't a multiple of their
alignments

In the following code, the first element is aligned on a 16-byte
boundary, but the remaining elements aren't:

```
typedef char int8_a16 __attribute__((aligned(16)));
int8_a16 array[4];
```

Currently clang doesn't reject the code, but it should since it can
cause crashes at runtime. This patch also fixes assertion failures in
CodeGen caused by the changes in https://reviews.llvm.org/D123649.

Differential Revision: https://reviews.llvm.org/D133711
15 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGenCXX/override-layout-packed-base.cpp
clang/test/CodeGenCXX/ubsan-new-checks.cpp
clang/test/Layout/ms-aligned-array.c
clang/test/Layout/ms-x86-misalignedarray.cpp
clang/test/Sema/align-x86-64.c
clang/test/Sema/align-x86.c
clang/test/Sema/attr-aligned.c
clang/test/SemaCXX/align-x86.cpp
clang/test/SemaCXX/array-alignment.cpp [new file with mode: 0644]
clang/test/SemaCXX/warn-new-overaligned.cpp