Fix #11373 typedef: not simplified after inline keyword (#4574)

This commit is contained in:
chrchr-github 2022-11-02 15:15:33 +01:00 committed by GitHub
parent d19bb758bd
commit e4c5f36af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -1234,7 +1234,7 @@ void Tokenizer::simplifyTypedef()
}
// check for typedef that can be substituted
else if ((tok2->isNameOnly() || (tok2->isName() && tok2->isExpandedMacro())) &&
else if ((tok2->isNameOnly() || (tok2->isName() && (tok2->isExpandedMacro() || tok2->isInline()))) &&
(Token::simpleMatch(tok2, pattern.c_str(), pattern.size()) ||
(inMemberFunc && tok2->str() == typeName->str()))) {
// member function class variables don't need qualification

View File

@ -397,14 +397,19 @@ private:
" typedef float float_t ;\n"
" inline VL::float_t fast_atan2(VL::float_t y, VL::float_t x){}\n"
"}";
const char expected[] =
"namespace VL { "
""
"float fast_atan2 ( float y , float x ) { } "
"}";
ASSERT_EQUALS(expected, tok(code, false));
// ticket #11373
const char code1[] =
"typedef int foo;\n"
"inline foo f();\n";
const char expected1[] = "int f ( ) ;";
ASSERT_EQUALS(expected1, tok(code1, false));
}
void simplifyTypedef7() {