Skip to content

Commit

Permalink
Fix #12929: ValueType: char literal '\'' gets valuetype 'int'
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Jul 11, 2024
1 parent 223a9ad commit 9ac1525
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7422,7 +7422,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
} else if (tok->isLong()) {
valuetype.originalTypeName = "wchar_t";
valuetype.type = ValueType::Type::WCHAR_T;
} else if ((tok->tokType() == Token::eChar) && ((!tok->isCpp() && tok->isCChar()) || (tok->isCMultiChar()))) {
} else if ((tok->tokType() == Token::eChar) && ((!tok->isCpp() && tok->isCChar()) || (tok->isCMultiChar() && !isPrefixStringCharLiteral(tok->str(), '\'', "\'\\")))) {
valuetype.type = ValueType::Type::INT;
valuetype.sign = ValueType::Sign::SIGNED;
}
Expand Down
1 change: 1 addition & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8887,6 +8887,7 @@ class TestSymbolDatabase : public TestFixture {

// char
ASSERT_EQUALS("char", typeOf("'a';", "'a'", true));
ASSERT_EQUALS("char", typeOf("'\\\'';", "'\\\''", true));
ASSERT_EQUALS("signed int", typeOf("'a';", "'a'", false));
ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", true));
ASSERT_EQUALS("wchar_t", typeOf("L'a';", "L'a'", false));
Expand Down

0 comments on commit 9ac1525

Please sign in to comment.