diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d14d43e4275..e98b7127498 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6592,10 +6592,12 @@ void SymbolDatabase::setValueType(Token* tok, const Enumerator& enumerator, cons valuetype.setDebugPath(tok, loc); valuetype.typeScope = enumerator.scope; const Token * type = enumerator.scope->enumType; + if (type && type->astParent()) + type = type->astParent(); if (type) { valuetype.type = ValueType::typeFromString(type->str(), type->isLong()); - if (valuetype.type == ValueType::Type::UNKNOWN_TYPE && type->isStandardType()) - valuetype.fromLibraryType(type->str(), mSettings); + if (valuetype.type == ValueType::Type::UNKNOWN_TYPE) + valuetype.fromLibraryType(type->expressionString(), mSettings); if (valuetype.isIntegral()) { if (type->isSigned()) diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index c66a140d701..166092af2d7 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1578,7 +1578,7 @@ class TestSuppressions : public TestFixture { } } - void addSuppressionLineMultiple() { + void addSuppressionLineMultiple() const { SuppressionList supprlist; ASSERT_EQUALS("", supprlist.addSuppressionLine("syntaxError")); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 198d882ed13..f5a774ee821 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -455,6 +455,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(enum16); TEST_CASE(enum17); TEST_CASE(enum18); + TEST_CASE(enum19); TEST_CASE(sizeOfType); @@ -6664,6 +6665,23 @@ class TestSymbolDatabase : public TestFixture { } } + void enum19() { + { + GET_SYMBOL_DB("enum : std::int8_t { I = -1 };\n" // #13528 + "enum : int8_t { J = -1 };\n" + "enum : char { K = -1 };\n"); + const Token* I = Token::findsimplematch(tokenizer.tokens(), "I"); + ASSERT(I && I->valueType() && I->valueType()->isEnum()); + ASSERT_EQUALS(I->valueType()->type, ValueType::CHAR); + const Token* J = Token::findsimplematch(I, "J"); + ASSERT(J && J->valueType() && J->valueType()->isEnum()); + ASSERT_EQUALS(J->valueType()->type, ValueType::CHAR); + const Token* K = Token::findsimplematch(J, "K"); + ASSERT(K && K->valueType() && K->valueType()->isEnum()); + ASSERT_EQUALS(K->valueType()->type, ValueType::CHAR); + } + } + void sizeOfType() { // #7615 - crash in Symboldatabase::sizeOfType() GET_SYMBOL_DB("enum e;\n"