diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2025-08-19 12:06:01 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2025-08-21 15:55:48 -0700 |
| commit | db05d302150b28a1bc4362eecd197a57d98bfe65 (patch) | |
| tree | 98deebc89ee65974f5e9c928a26dd8f3f6ae18e8 /src/corelib/kernel/qmetaobject.cpp | |
| parent | 5e6991b880e4dc3a8dc4b5904bc6ddc0b65c517a (diff) | |
QMetaObject::access: statically assert that the constants match
The MethodFlags constants used to be in a private header, but we still
don't require either header to include the other, so asserting somewhere
that uses them both suffices.
Drive-by add shifting, which currently is by zero.
Change-Id: I5fbf353571fe8df98e95fffd1e031ef9de0b81db
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3c0ee3851fe..17a9856dfd2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2481,9 +2481,13 @@ bool QMetaMethod::isConst() const */ QMetaMethod::Access QMetaMethod::access() const { + constexpr int AccessShift = QtPrivate::qConstexprCountTrailingZeroBits(AccessMask); + static_assert(AccessPrivate >> AccessShift == Private); + static_assert(AccessProtected >> AccessShift == Protected); + static_assert(AccessPublic >> AccessShift == Public); if (!mobj) return Private; - return (QMetaMethod::Access)(data.flags() & AccessMask); + return Access((data.flags() & AccessMask) >> AccessShift); } /*! |
