diff --git a/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp b/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp index f78e4e9338e..82f1e63eea0 100644 --- a/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp +++ b/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp @@ -216,5 +216,16 @@ void FullySpecifiedType::setFlags(unsigned flags) bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, Matcher *matcher) const { + static const unsigned flagsMask = [](){ + FullySpecifiedType ty; + ty.f._isConst = true; + ty.f._isVolatile = true; + ty.f._isSigned = true; + ty.f._isUnsigned = true; + return ty._flags; + }(); + + if ((_flags & flagsMask) != (otherTy._flags & flagsMask)) + return false; return type()->match(otherTy.type(), matcher); } diff --git a/tests/auto/cplusplus/misc/tst_misc.cpp b/tests/auto/cplusplus/misc/tst_misc.cpp index c3497613968..69679058f0a 100644 --- a/tests/auto/cplusplus/misc/tst_misc.cpp +++ b/tests/auto/cplusplus/misc/tst_misc.cpp @@ -51,6 +51,8 @@ private slots: void findBreakpoints3(); void astPathOnGeneratedTokens(); + + void typeMatcher(); }; void tst_Misc::diagnosticClient_error() @@ -244,5 +246,30 @@ void tst_Misc::astPathOnGeneratedTokens() } } +void tst_Misc::typeMatcher() +{ + IntegerType dummyType(IntegerType::Int); + FullySpecifiedType type1(&dummyType); + FullySpecifiedType type2(&dummyType); + + for (int i = 0; i < (1<<8); ++i) { + type1.setConst (i & (1 << 0)); + type1.setVolatile(i & (1 << 1)); + type1.setSigned (i & (1 << 2)); + type1.setUnsigned(i & (1 << 3)); + + type2.setConst (i & (1 << 4)); + type2.setVolatile(i & (1 << 5)); + type2.setSigned (i & (1 << 6)); + type2.setUnsigned(i & (1 << 7)); + + const unsigned type1Specifiers = (i & 0x0f); + const unsigned type2Specifiers = (i >> 4); + const bool sameSpecifiers = type1Specifiers == type2Specifiers; + QCOMPARE(type1.match(type2), sameSpecifiers); + QCOMPARE(type2.match(type1), sameSpecifiers); + } +} + QTEST_MAIN(tst_Misc) #include "tst_misc.moc"