Ticket #8878: Properly simplify typedefs within template instantiations. (#1656)

This commit is contained in:
Simon Martin 2019-02-10 09:45:33 +01:00 committed by Daniel Marjamäki
parent 67bfed10a5
commit eaaff30e65
2 changed files with 14 additions and 2 deletions

View File

@ -1494,7 +1494,8 @@ void Tokenizer::simplifyTypedef()
tok2 = tok2->next(); tok2 = tok2->next();
if (openParenthesis) { if (openParenthesis) {
// skip over name // Skip over name, if any
if (Token::Match(tok2->next(), "%name%"))
tok2 = tok2->next(); tok2 = tok2->next();
tok2->insertToken(")"); tok2->insertToken(")");

View File

@ -164,6 +164,7 @@ private:
TEST_CASE(simplifyTypedef124); // ticket #7792 TEST_CASE(simplifyTypedef124); // ticket #7792
TEST_CASE(simplifyTypedef125); // #8749 - typedef char A[10]; p = new A[1]; TEST_CASE(simplifyTypedef125); // #8749 - typedef char A[10]; p = new A[1];
TEST_CASE(simplifyTypedef126); // ticket #5953 TEST_CASE(simplifyTypedef126); // ticket #5953
TEST_CASE(simplifyTypedef127); // ticket #8878
TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685 TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -2540,6 +2541,16 @@ private:
ASSERT_EQUALS(exp, tok(code, false)); ASSERT_EQUALS(exp, tok(code, false));
} }
void simplifyTypedef127() { // #8878
const char code[] = "class a; typedef int (a::*b); "
"template <long, class> struct c; "
"template <int g> struct d { enum { e = c<g, b>::f }; };";
const char exp [] = "class a ; "
"template < long , class > struct c ; "
"template < int g > struct d { enum Anonymous0 { e = c < g , int ( a :: * ) > :: f } ; } ;";
ASSERT_EQUALS(exp, tok(code, false));
}
void simplifyTypedefFunction1() { void simplifyTypedefFunction1() {
{ {
const char code[] = "typedef void (*my_func)();\n" const char code[] = "typedef void (*my_func)();\n"