#6345 Tokenizer::simplifyTypedef() adds redundant 'typename' to declaration
This commit is contained in:
parent
af9b67562b
commit
8416be4d9d
|
@ -1266,6 +1266,11 @@ void Tokenizer::simplifyTypedef()
|
||||||
Token::simpleMatch(tok2->tokAt(-2), "operator const"))
|
Token::simpleMatch(tok2->tokAt(-2), "operator const"))
|
||||||
inOperator = true;
|
inOperator = true;
|
||||||
|
|
||||||
|
if (typeStart->str() == "typename" && tok2->strAt(-1)=="typename") {
|
||||||
|
// Remove one typename if it is already contained in the goal
|
||||||
|
typeStart = typeStart->next();
|
||||||
|
}
|
||||||
|
|
||||||
// skip over class or struct in derived class declaration
|
// skip over class or struct in derived class declaration
|
||||||
bool structRemoved = false;
|
bool structRemoved = false;
|
||||||
if (isDerived && Token::Match(typeStart, "class|struct")) {
|
if (isDerived && Token::Match(typeStart, "class|struct")) {
|
||||||
|
|
|
@ -141,6 +141,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef108); // ticket #4777
|
TEST_CASE(simplifyTypedef108); // ticket #4777
|
||||||
TEST_CASE(simplifyTypedef109); // ticket #1823 - rvalue reference
|
TEST_CASE(simplifyTypedef109); // ticket #1823 - rvalue reference
|
||||||
TEST_CASE(simplifyTypedef110); // ticket #6268
|
TEST_CASE(simplifyTypedef110); // ticket #6268
|
||||||
|
TEST_CASE(simplifyTypedef111); // ticket #6345
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -2374,6 +2375,39 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef111() { // ticket #6345
|
||||||
|
const char code1[] = "typedef typename A B;\n"
|
||||||
|
"typedef typename B C;\n"
|
||||||
|
"typename C c;\n";
|
||||||
|
const char expected1[] = "typename A c ;";
|
||||||
|
ASSERT_EQUALS(expected1, tok(code1));
|
||||||
|
|
||||||
|
const char code2[] = "typedef typename A B;\n"
|
||||||
|
"typedef typename B C;\n"
|
||||||
|
"C c;\n";
|
||||||
|
const char expected2[] = "typename A c ;";
|
||||||
|
ASSERT_EQUALS(expected2, tok(code2));
|
||||||
|
|
||||||
|
const char code3[] = "typedef typename A B;\n"
|
||||||
|
"typedef B C;\n"
|
||||||
|
"C c;\n";
|
||||||
|
const char expected3[] = "typename A c ;";
|
||||||
|
ASSERT_EQUALS(expected3, tok(code3));
|
||||||
|
|
||||||
|
const char code4[] = "typedef A B;\n"
|
||||||
|
"typedef typename B C;\n"
|
||||||
|
"C c;\n";
|
||||||
|
const char expected4[] = "typename A c ;";
|
||||||
|
ASSERT_EQUALS(expected4, tok(code4));
|
||||||
|
|
||||||
|
const char code5[] = "typedef A B;\n"
|
||||||
|
"typedef B C;\n"
|
||||||
|
"C c;\n";
|
||||||
|
const char expected5[] = "A c ;";
|
||||||
|
ASSERT_EQUALS(expected5, tok(code5));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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