Fixed #7058 (Tokenizer::simplifyTypedef: wrong simplification of enum constant 'AB::A' if AB is a struct typedef)
This commit is contained in:
parent
ec87b09d89
commit
fe4fac7eb2
|
@ -1201,7 +1201,7 @@ void Tokenizer::simplifyTypedef()
|
|||
tok2 = tok2->next();
|
||||
}
|
||||
}
|
||||
} else if (tok2->tokAt(-2) && Token::Match(tok2->tokAt(-2), "%type% *|&")) {
|
||||
} else if (Token::Match(tok2->tokAt(-2), "%type% *|&")) {
|
||||
// Ticket #5868: Don't substitute variable names
|
||||
} else if (tok2->previous()->str() != ".") {
|
||||
simplifyType = true;
|
||||
|
@ -1264,6 +1264,8 @@ void Tokenizer::simplifyTypedef()
|
|||
structRemoved = true;
|
||||
typeStart = typeStart->next();
|
||||
}
|
||||
if (typeStart->str() == "struct" && Token::Match(tok2, "%name% ::"))
|
||||
typeStart = typeStart->next();
|
||||
|
||||
// start substituting at the typedef name by replacing it with the type
|
||||
tok2->str(typeStart->str());
|
||||
|
|
|
@ -150,6 +150,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef111); // ticket #6345
|
||||
TEST_CASE(simplifyTypedef112); // ticket #6048
|
||||
TEST_CASE(simplifyTypedef113); // ticket #7030
|
||||
TEST_CASE(simplifyTypedef114); // ticket #7058 - skip "struct", AB::..
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -2414,6 +2415,13 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedef114() { // ticket #7058
|
||||
const char code[] = "typedef struct { enum {A,B}; } AB;\n"
|
||||
"x=AB::B;";
|
||||
const char expected[] = "struct AB { } ; x = 1 ;";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue