Q<Typed>Permission: add alignment checks for future BC changes
Ensure that the classes using ShortData have the same size (already done) and alignment (this patch) as classes that just have a d-pointer. Change-Id: If30352a0bc4beb4b505d6e0eab5077c9c16456ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 2d254afead50ab0d323f562ac820f876474f3961) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
bde41bcb73
commit
f46bc118cc
@ -277,11 +277,18 @@ const void *QPermission::data(QMetaType requestedType) const
|
||||
return m_data.data();
|
||||
}
|
||||
|
||||
// check alignof(AlignmentCheck) instead of alignof(void*), in case
|
||||
// pointers have different alignment inside structs:
|
||||
struct AlignmentCheck { void *p; };
|
||||
|
||||
#define QT_PERMISSION_IMPL_COMMON(ClassName) \
|
||||
/* Class##Private is unused until we need it: */ \
|
||||
static_assert(sizeof(ClassName) == sizeof(void*), \
|
||||
"You have added too many members to " #ClassName "::ShortData. " \
|
||||
"Decrease their size or switch to using a d-pointer."); \
|
||||
static_assert(alignof(ClassName) == alignof(AlignmentCheck), \
|
||||
"You have added members to " #ClassName "::ShortData that are overaligned. " \
|
||||
"Decrease their alignment or switch to using a d-pointer."); \
|
||||
ClassName::ClassName(const ClassName &other) noexcept = default; \
|
||||
ClassName::~ClassName() = default; \
|
||||
ClassName &ClassName::operator=(const ClassName &other) noexcept = default; \
|
||||
|
Loading…
x
Reference in New Issue
Block a user