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. Pick-to: 6.5 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>bb10
parent
3f33ed249b
commit
2d254afead
|
|
@ -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…
Reference in New Issue