[PATCH] D133711: [Sema] Reject array element types whose alignments are larger than their sizes

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 10:15:59 PDT 2022


ahatanak created this revision.
ahatanak added reviewers: efriedma, rjmccall, rnk, sepavloff.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133711

Files:
  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/ubsan-new-checks.cpp
  clang/test/Layout/ms-aligned-array.c
  clang/test/Sema/attr-aligned.c
  clang/test/SemaCXX/array-alignment.cpp
  clang/test/SemaCXX/warn-new-overaligned.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133711.459493.patch
Type: text/x-patch
Size: 9306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220912/962f3949/attachment-0001.bin>


More information about the cfe-commits mailing list