parent
775af5ec70
commit
5a21851bb7
|
@ -3236,9 +3236,18 @@ bool Tokenizer::simplifyUsing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// just replace simple type aliases
|
// Is this a "T()" expression where T is a pointer type?
|
||||||
TokenList::copyTokens(tok1, start, usingEnd->previous());
|
if (Token::Match(tok1, "%name% ( )") && !pointers.empty()) {
|
||||||
tok1->deleteThis();
|
Token* tok2 = tok1->linkAt(1);
|
||||||
|
tok1->deleteThis();
|
||||||
|
TokenList::copyTokens(tok1, start, usingEnd->previous());
|
||||||
|
tok2->insertToken("0");
|
||||||
|
after = tok2->next();
|
||||||
|
}
|
||||||
|
else { // just replace simple type aliases
|
||||||
|
TokenList::copyTokens(tok1, start, usingEnd->previous());
|
||||||
|
tok1->deleteThis();
|
||||||
|
}
|
||||||
substitute = true;
|
substitute = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
TEST_CASE(simplifyUsing26); // #11090
|
TEST_CASE(simplifyUsing26); // #11090
|
||||||
TEST_CASE(simplifyUsing27);
|
TEST_CASE(simplifyUsing27);
|
||||||
TEST_CASE(simplifyUsing28);
|
TEST_CASE(simplifyUsing28);
|
||||||
|
TEST_CASE(simplifyUsing29);
|
||||||
|
|
||||||
TEST_CASE(simplifyUsing8970);
|
TEST_CASE(simplifyUsing8970);
|
||||||
TEST_CASE(simplifyUsing8971);
|
TEST_CASE(simplifyUsing8971);
|
||||||
|
@ -684,6 +685,14 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyUsing29() { // #11981
|
||||||
|
const char code[] = "using T = int*;\n"
|
||||||
|
"void f(T = T()) {}\n";
|
||||||
|
const char expected[] = "void f ( int * = ( int * ) 0 ) { }";
|
||||||
|
ASSERT_EQUALS(expected, tok(code, cppcheck::Platform::Type::Native, /*debugwarnings*/ true));
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyUsing8970() {
|
void simplifyUsing8970() {
|
||||||
const char code[] = "using V = std::vector<int>;\n"
|
const char code[] = "using V = std::vector<int>;\n"
|
||||||
"struct A {\n"
|
"struct A {\n"
|
||||||
|
|
Loading…
Reference in New Issue