Merge pull request #700 from simartin/ticket_6998

Ticket #6998: Properly handle "typedef unsigned T;" constructs.
This commit is contained in:
amai2012 2015-10-24 15:24:27 +02:00
commit 116c10c7d6
2 changed files with 13 additions and 1 deletions

View File

@ -704,7 +704,8 @@ void Tokenizer::simplifyTypedef()
} else if (Token::Match(tokOffset, "%type%")) {
typeStart = tokOffset;
while (Token::Match(tokOffset, "const|signed|unsigned|struct|enum %type%") ||
while (Token::Match(tokOffset, "const|struct|enum %type%") ||
(Token::Match(tokOffset, "signed|unsigned %type%") && tokOffset->next()->isStandardType()) ||
(tokOffset->next() && tokOffset->next()->isStandardType()))
tokOffset = tokOffset->next();

View File

@ -151,6 +151,7 @@ private:
TEST_CASE(simplifyTypedef112); // ticket #6048
TEST_CASE(simplifyTypedef113); // ticket #7030
TEST_CASE(simplifyTypedef114); // ticket #7058 - skip "struct", AB::..
TEST_CASE(simplifyTypedef115); // ticket #6998
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -2422,6 +2423,16 @@ private:
ASSERT_EQUALS(expected, tok(code));
}
void simplifyTypedef115() { // ticket #6998
const char code[] = "typedef unsigned unsignedTypedef;\n"
"unsignedTypedef t1 ;\n"
"unsigned t2 ;";
const char expected[] = "unsigned int t1 ; "
"unsigned int t2 ;";
ASSERT_EQUALS(expected, tok(code, false));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"