qt: Fix -Wsfinae-incomplete warnings when building with GCC 16.x

According to the CMake documentation for `AUTOMOC`, all `moc` output
files that are not included in a source file are aggregated into the
CMake-generated `<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`, which is
added to the target's sources.

Within that single translation unit, `moc`-generated code checks the
completeness of a signal or slot parameter type while it is still only
forward-declared, and the type is completed later, when a subsequently
included `moc_*.cpp` file pulls in the header that defines it. GCC 16.x
diagnoses this pattern with the `-Wsfinae-incomplete` warning, which is
enabled by default.

Including the `moc` output files at the end of the corresponding source
files excludes them from `mocs_compilation.cpp`, so each one is
compiled in a translation unit where the relevant types are complete.

Additionally:
1. Some of the `BitcoinGUI` class's private members are gated with
   `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings
   when building with `-DENABLE_WALLET=OFF`.
2. `test/lint/lint-includes.py` is adjusted to allow new `#include`
   statements.
This commit is contained in:
Hennadii Stepanov
2026-07-20 12:23:51 +01:00
parent 18c05d9301
commit 51d36dfd07
5 changed files with 17 additions and 3 deletions

View File

@@ -70,7 +70,11 @@ def find_included_cpps():
if e.returncode > 1:
raise e
return included_cpps
# Exception: `#include <moc_*.cpp>` statements in src/qt source files are permitted.
# See:
# - https://doc.qt.io/qt-6/moc.html
# - https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html
return [i for i in included_cpps if not re.match(r"src/qt/[^:]+\.cpp:#include <moc_[^<>:]+\.cpp>$", i)]
def find_extra_boosts():