Merge pull request #700 from simartin/ticket_6998
Ticket #6998: Properly handle "typedef unsigned T;" constructs.
This commit is contained in:
commit
116c10c7d6
|
@ -704,7 +704,8 @@ void Tokenizer::simplifyTypedef()
|
||||||
} else if (Token::Match(tokOffset, "%type%")) {
|
} else if (Token::Match(tokOffset, "%type%")) {
|
||||||
typeStart = tokOffset;
|
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->next() && tokOffset->next()->isStandardType()))
|
||||||
tokOffset = tokOffset->next();
|
tokOffset = tokOffset->next();
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef112); // ticket #6048
|
TEST_CASE(simplifyTypedef112); // ticket #6048
|
||||||
TEST_CASE(simplifyTypedef113); // ticket #7030
|
TEST_CASE(simplifyTypedef113); // ticket #7030
|
||||||
TEST_CASE(simplifyTypedef114); // ticket #7058 - skip "struct", AB::..
|
TEST_CASE(simplifyTypedef114); // ticket #7058 - skip "struct", AB::..
|
||||||
|
TEST_CASE(simplifyTypedef115); // ticket #6998
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -2422,6 +2423,16 @@ private:
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
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() {
|
void simplifyTypedefFunction1() {
|
||||||
{
|
{
|
||||||
const char code[] = "typedef void (*my_func)();\n"
|
const char code[] = "typedef void (*my_func)();\n"
|
||||||
|
|
Loading…
Reference in New Issue