parent
33981fe42c
commit
42a64d4d39
|
@ -1942,6 +1942,8 @@ void Tokenizer::simplifyTypedefCpp()
|
|||
tok2 = tok2->next();
|
||||
tok2->next()->insertToken("0");
|
||||
}
|
||||
if (Token::Match(tok2->tokAt(-1), "class|struct|union") && tok2->strAt(-1) == typeStart->str())
|
||||
tok2->deletePrevious();
|
||||
tok2->str(typeStart->str());
|
||||
|
||||
// restore qualification if it was removed
|
||||
|
|
|
@ -212,6 +212,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef146);
|
||||
TEST_CASE(simplifyTypedef147);
|
||||
TEST_CASE(simplifyTypedef148);
|
||||
TEST_CASE(simplifyTypedef149);
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -3443,6 +3444,18 @@ private:
|
|||
ASSERT_EQUALS("int & r = i ;", tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedef149() { // #12218
|
||||
const char* code{};
|
||||
code = "namespace N {\n"
|
||||
" typedef struct S {} S;\n"
|
||||
"}\n"
|
||||
"void g(int);\n"
|
||||
"void f() {\n"
|
||||
" g(sizeof(struct N::S));\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("namespace N { struct S { } ; } void g ( int ) ; void f ( ) { g ( sizeof ( struct N :: S ) ) ; }", tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue