]> granicus.if.org Git - clang/commit
This patch implements PR#22821.
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Fri, 12 Aug 2016 08:04:13 +0000 (08:04 +0000)
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Fri, 12 Aug 2016 08:04:13 +0000 (08:04 +0000)
commit6b8562e620455386ce67ed551fcbd0c6a8a2a5ff
tree79889696fa599a1c25188a0ce18ad81a5d6306ed
parent07598186adb6a73cc525056dd30f05d251961da0
This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
will silence the warning.

Differential Revision: https://reviews.llvm.org/D20561

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278483 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaCast.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp