Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13528 FN functionConst with overload and typed enum (regression) #7188

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ class TestSuppressions : public TestFixture {
}
}

void addSuppressionLineMultiple() {
void addSuppressionLineMultiple() const {
SuppressionList supprlist;

ASSERT_EQUALS("", supprlist.addSuppressionLine("syntaxError"));
Expand Down
18 changes: 18 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(enum16);
TEST_CASE(enum17);
TEST_CASE(enum18);
TEST_CASE(enum19);

TEST_CASE(sizeOfType);

Expand Down Expand Up @@ -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"
Expand Down
Loading