Skip to content

Commit 48171bc

Browse files
Fix #13528 FN functionConst with overload and typed enum (regression) (#7188)
1 parent 6f3e98e commit 48171bc

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/symboldatabase.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -6592,10 +6592,12 @@ void SymbolDatabase::setValueType(Token* tok, const Enumerator& enumerator, cons
65926592
valuetype.setDebugPath(tok, loc);
65936593
valuetype.typeScope = enumerator.scope;
65946594
const Token * type = enumerator.scope->enumType;
6595+
if (type && type->astParent())
6596+
type = type->astParent();
65956597
if (type) {
65966598
valuetype.type = ValueType::typeFromString(type->str(), type->isLong());
6597-
if (valuetype.type == ValueType::Type::UNKNOWN_TYPE && type->isStandardType())
6598-
valuetype.fromLibraryType(type->str(), mSettings);
6599+
if (valuetype.type == ValueType::Type::UNKNOWN_TYPE)
6600+
valuetype.fromLibraryType(type->expressionString(), mSettings);
65996601

66006602
if (valuetype.isIntegral()) {
66016603
if (type->isSigned())

test/testsuppressions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ class TestSuppressions : public TestFixture {
15781578
}
15791579
}
15801580

1581-
void addSuppressionLineMultiple() {
1581+
void addSuppressionLineMultiple() const {
15821582
SuppressionList supprlist;
15831583

15841584
ASSERT_EQUALS("", supprlist.addSuppressionLine("syntaxError"));

test/testsymboldatabase.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ class TestSymbolDatabase : public TestFixture {
455455
TEST_CASE(enum16);
456456
TEST_CASE(enum17);
457457
TEST_CASE(enum18);
458+
TEST_CASE(enum19);
458459

459460
TEST_CASE(sizeOfType);
460461

@@ -6664,6 +6665,23 @@ class TestSymbolDatabase : public TestFixture {
66646665
}
66656666
}
66666667

6668+
void enum19() {
6669+
{
6670+
GET_SYMBOL_DB("enum : std::int8_t { I = -1 };\n" // #13528
6671+
"enum : int8_t { J = -1 };\n"
6672+
"enum : char { K = -1 };\n");
6673+
const Token* I = Token::findsimplematch(tokenizer.tokens(), "I");
6674+
ASSERT(I && I->valueType() && I->valueType()->isEnum());
6675+
ASSERT_EQUALS(I->valueType()->type, ValueType::CHAR);
6676+
const Token* J = Token::findsimplematch(I, "J");
6677+
ASSERT(J && J->valueType() && J->valueType()->isEnum());
6678+
ASSERT_EQUALS(J->valueType()->type, ValueType::CHAR);
6679+
const Token* K = Token::findsimplematch(J, "K");
6680+
ASSERT(K && K->valueType() && K->valueType()->isEnum());
6681+
ASSERT_EQUALS(K->valueType()->type, ValueType::CHAR);
6682+
}
6683+
}
6684+
66676685
void sizeOfType() {
66686686
// #7615 - crash in Symboldatabase::sizeOfType()
66696687
GET_SYMBOL_DB("enum e;\n"

0 commit comments

Comments
 (0)