Pacify MSVC compiler incorrectly warning about unused variable
Under some circumstances, MSVC seems to complain about SlotArgumentCount
being unused
qobject.h(210): warning C4189: 'SlotArgumentCount': local variable is
initialized but not referenced
note: see reference to function template instantiation
'QMetaObject::Connection QObject::connect<void(__cdecl QAction::* )(bool),
main::<lambda_1>>(const QAction *,Func1,
const QtPrivate::ContextTypeForFunctor<main::<lambda_1>,void>::ContextType *,
Func2 &&,Qt::ConnectionType)' being compiled
This is nonsense, as SlotArgumentCount is used in the next line, to
construct the list of signal arguments, but the workaround to declare
the variable as [[maybe_unused]] is trivial.
Add a connect statement to the test case that creates such a connection.
This does not produce any warning with or without the attribute (and if
it did, the build would fail for CI configuratinos setting -Werror).
Pick-to: 6.6
Fixes: QTBUG-114781
Change-Id: I4ee6f7d57c2836ef3dd9741d037d48181af2cdec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
bb10
parent
c33fd574c9
commit
2b9ef2eb44
|
|
@ -207,6 +207,7 @@ public:
|
|||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
} else {
|
||||
constexpr int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<std::decay_t<Func2>, typename SignalType::Arguments>::Value;
|
||||
[[maybe_unused]]
|
||||
constexpr int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
|
||||
typedef typename QtPrivate::FunctorReturnType<std::decay_t<Func2>, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value>::Value SlotReturnType;
|
||||
|
||||
|
|
|
|||
|
|
@ -6075,6 +6075,7 @@ void tst_QObject::connectFunctorArgDifference()
|
|||
|
||||
connect(&timer, &QTimer::timeout, [=](){});
|
||||
connect(&timer, &QTimer::objectNameChanged, [=](const QString &){});
|
||||
connect(&timer, &QTimer::objectNameChanged, this, [](){});
|
||||
connect(qApp, &QCoreApplication::aboutToQuit, [=](){});
|
||||
|
||||
connect(&timer, &QTimer::objectNameChanged, [=](){});
|
||||
|
|
|
|||
Loading…
Reference in New Issue