Fix warnings from gcc 11.2 about ignoring [[maybe_unused]]

QQmltcObjectCreationHelper::m_size was declared [[maybe_unused]]
because it's only used in assertions; but this means the compiler can
see, in a debug build, that it is used, so the [[maybe_unused]] is
ignored; which means a build gets spammed with warnings about the
attempt to suppress an unused member warning. Replace the
[[maybe_unused]] on the declaration with a Q_UNUSED(m_size) in the
constructor body.

Change-Id: I747059d091384b4b90069be30bc8d5ffa6dbc7d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
Edward Welbourne 2021-11-26 16:52:21 +01:00
parent ab60c3fe70
commit 844a939af5
1 changed files with 2 additions and 1 deletions

View File

@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
class QQmltcObjectCreationHelper
{
QObject **m_data = nullptr; // QObject* array
[[maybe_unused]] const qsizetype m_size = 0; // size of m_data array, exists for bounds checking
const qsizetype m_size = 0; // size of m_data array, exists for bounds checking
const qsizetype m_offset = 0; // global offset into m_data array
const qsizetype m_nonRoot = 1; // addresses the "+ 1" in QQmltcObjectCreationBase::m_objects
@ -81,6 +81,7 @@ public:
QQmltcObjectCreationHelper(QObject **data, qsizetype size)
: m_data(data), m_size(size), m_nonRoot(0 /* root object */)
{
Q_UNUSED(m_size);
}
/*!