Skip to content

Commit

Permalink
Add tests for #12475 (also fixed by this)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 13, 2024
1 parent 7f44765 commit e8fd8e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class TestSimplifyTypedef : public TestFixture {
TEST_CASE(simplifyTypedef147);
TEST_CASE(simplifyTypedef148);
TEST_CASE(simplifyTypedef149);
TEST_CASE(simplifyTypedef150);

TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
Expand Down Expand Up @@ -3511,6 +3512,26 @@ class TestSimplifyTypedef : public TestFixture {
"}\n";
ASSERT_EQUALS("namespace N { enum E { } ; } void g ( int ) ; void f ( ) { g ( sizeof ( enum N :: E ) ) ; }", tok(code));
}

void simplifyTypedef150() { // #12475
const char* code{}, *exp{};
code = "struct S {\n"
" std::vector<int> const& h(int);\n"
"};\n"
"void g(auto, int);\n"
"void f() {\n"
" typedef std::vector<int> const& (S::* func_t)(int);\n"
" g(func_t(&S::h), 5);\n"
"}\n";
exp = "struct S { "
"const std :: vector < int > & h ( int ) ; "
"} ; "
"void g ( auto , int ) ; "
"void f ( ) { "
"g ( const std :: vector < int > & ( S :: * ( & S :: h ) ) ( int ) , 5 ) ; "
"}";
ASSERT_EQUALS(exp, tok(code)); // TODO: don't create invalid code
}

void simplifyTypedefFunction1() {
{
Expand Down
1 change: 1 addition & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6587,6 +6587,7 @@ class TestTokenizer : public TestFixture {
ASSERT_EQUALS("x{( forbc;;(", testAst("x({ for(a;b;c){} });"));
ASSERT_EQUALS("PT.(", testAst("P->~T();")); // <- The "T" token::function() will be a destructor
ASSERT_EQUALS("double&(4[", testAst("void f(double(&)[4]) {}"));
ASSERT_EQUALS("voidu*", testAst("int* g ( void* (f) (void*), void* u);")); // #12475
}

void asttemplate() { // uninstantiated templates will have <,>,etc..
Expand Down

0 comments on commit e8fd8e6

Please sign in to comment.