Merge pull request #786 from prozak/master
- fix for #5749 defect: internal error
This commit is contained in:
commit
7a8a6695a4
|
@ -1430,9 +1430,19 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok2->insertToken("*");
|
tok2->insertToken("*");
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
} else {
|
} else {
|
||||||
tok2->insertToken("(");
|
// This is the case of casting operator.
|
||||||
tok2 = tok2->next();
|
// Name is not available, and () should not be
|
||||||
Token *tok3 = tok2;
|
// inserted
|
||||||
|
bool castOperator = inOperator && Token::Match(tok2, "%type% (");
|
||||||
|
|
||||||
|
Token *tok3;
|
||||||
|
|
||||||
|
if (!castOperator) {
|
||||||
|
tok2->insertToken("(");
|
||||||
|
tok2 = tok2->next();
|
||||||
|
|
||||||
|
tok3 = tok2;
|
||||||
|
}
|
||||||
|
|
||||||
const Token *tok4 = namespaceStart;
|
const Token *tok4 = namespaceStart;
|
||||||
|
|
||||||
|
@ -1447,12 +1457,15 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok2->insertToken("*");
|
tok2->insertToken("*");
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
// skip over name
|
if (!castOperator) {
|
||||||
tok2 = tok2->next();
|
// skip over name
|
||||||
|
tok2 = tok2->next();
|
||||||
|
|
||||||
tok2->insertToken(")");
|
tok2->insertToken(")");
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
Token::createMutualLinks(tok2, tok3);
|
|
||||||
|
Token::createMutualLinks(tok2, tok3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (typeOf) {
|
} else if (typeOf) {
|
||||||
tok2 = copyTokens(tok2, argStart, argEnd);
|
tok2 = copyTokens(tok2, argStart, argEnd);
|
||||||
|
|
|
@ -151,6 +151,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef115); // ticket #6998
|
TEST_CASE(simplifyTypedef115); // ticket #6998
|
||||||
TEST_CASE(simplifyTypedef116); // ticket #5624
|
TEST_CASE(simplifyTypedef116); // ticket #5624
|
||||||
TEST_CASE(simplifyTypedef117); // ticket #6507
|
TEST_CASE(simplifyTypedef117); // ticket #6507
|
||||||
|
TEST_CASE(simplifyTypedef118); // ticket #5749
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -2354,6 +2355,22 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef118() { // #5749
|
||||||
|
const char code[] = "struct ClassyClass {\n"
|
||||||
|
"int id;\n"
|
||||||
|
"typedef int (ClassyClass::*funky_type);\n"
|
||||||
|
"operator funky_type() {\n"
|
||||||
|
"return &ClassyClass::id;\n"
|
||||||
|
"}}";
|
||||||
|
const char expected[] = "struct ClassyClass { "
|
||||||
|
"int id ; "
|
||||||
|
"operatorintClassyClass::* ( ) { "
|
||||||
|
"return & ClassyClass :: id ; "
|
||||||
|
"} }";
|
||||||
|
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