diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-08-01 17:32:25 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-08-02 16:00:47 +0200 |
commit | a5377f32e12eca0c936325c1fda7160978f324c1 (patch) | |
tree | 3916cfc3bd466eed3ad50d03e810184646aff929 | |
parent | 8c500c34de829f592e07117730d7b021de1aca30 (diff) |
qmltc: fix GCC13 warnings "class X is implicitly friend with itself"
This happens because the generated code contains
class X {
~~~~
private:
friend class X; // warning here
};
Says GCC13 (e.g.):
tests/auto/qml/qmltc/QmltcTests/.qmltc/qmltc_test_module/inlinecomponents.h:421:18: warning: class ‘QmltcTests::inlineComponents_IC0’ is implicitly friends with itself
421 | friend class inlineComponents_IC0;
| ^~~~~~~~~~~~~~~~~~~~
It seems the intended check for documentRoot doesn't work in all
cases, so do the check on the class-name level.
There appears to be no -W flag to control this warning, therefore no
apparent way to suppress it, so we need to fix it.
Amends either b89a92053e1a4565d37f75831db1c6c90c21bce6 or
0990b892cab819f210120f8a9f9ca48522bde412. I didn't dig into it
further.
Pick-to: 6.6 6.5
Change-Id: I3fe653a398ea5b7a3e045fd3ea8dfb5d5c0f2e5c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | tools/qmltc/qmltccompiler.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp index a623a683e6..34077a29d8 100644 --- a/tools/qmltc/qmltccompiler.cpp +++ b/tools/qmltc/qmltccompiler.cpp @@ -189,7 +189,8 @@ void QmltcCompiler::compileType( // make document root a friend to allow it to access init and endInit const QString rootInternalName = m_visitor->inlineComponent(type->enclosingInlineComponentName())->internalName(); - current.otherCode << u"friend class %1;"_s.arg(rootInternalName); + if (rootInternalName != current.cppType) // avoid GCC13 warning on self-befriending + current.otherCode << "friend class %1;"_L1.arg(rootInternalName); } if (documentRoot || inlineComponent) { auto name = type->inlineComponentName() |