Why do we even split any declarations in the first place?
This commit is contained in:
parent
780b742568
commit
d24074f7b1
|
@ -891,7 +891,8 @@ namespace {
|
|||
tok->deleteThis();
|
||||
|
||||
// Unsplit variable declarations
|
||||
if (Token::Match(tok4->previous(), "] ; %name% = {") && tok4->isSplittedVarDeclEq()) {
|
||||
if (tok4 && tok4->isSplittedVarDeclEq() &&
|
||||
((tok4->isCpp() && Token::Match(tok4->tokAt(-2), "& %name% ;")) || Token::Match(tok4->previous(), "] ; %name% = {"))) {
|
||||
tok4->deleteNext();
|
||||
tok4->deleteThis();
|
||||
}
|
||||
|
|
|
@ -211,6 +211,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef145); // #9353
|
||||
TEST_CASE(simplifyTypedef146);
|
||||
TEST_CASE(simplifyTypedef147);
|
||||
TEST_CASE(simplifyTypedef148);
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -3435,6 +3436,13 @@ private:
|
|||
tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedef148() {
|
||||
const char* code{};
|
||||
code = "typedef int& R;\n" // #12166
|
||||
"R r = i;\n";
|
||||
ASSERT_EQUALS("int & r = i ;", tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue