Skip to content

Commit c5bfd21

Browse files
IOBYTEdanmar
authored andcommitted
Tokenizer::simplifyTypedef: Add test that danmar#5191 is fixed (function pointer)
1 parent e3892a9 commit c5bfd21

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/testsimplifytypedef.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class TestSimplifyTypedef : public TestFixture {
155155
TEST_CASE(simplifyTypedefFunction7);
156156
TEST_CASE(simplifyTypedefFunction8);
157157
TEST_CASE(simplifyTypedefFunction9);
158+
TEST_CASE(simplifyTypedefFunction10); // #5191
158159

159160
TEST_CASE(simplifyTypedefShadow); // #4445 - shadow variable
160161
}
@@ -3120,6 +3121,25 @@ class TestSimplifyTypedef : public TestFixture {
31203121
}
31213122
}
31223123

3124+
void simplifyTypedefFunction10() {
3125+
const char code[] = "enum Format_E1 { FORMAT11 FORMAT12 } Format_T1;\n"
3126+
"namespace MySpace {\n"
3127+
" enum Format_E2 { FORMAT21 FORMAT22 } Format_T2;\n"
3128+
"}\n"
3129+
"typedef Format_E1 (**PtrToFunPtr_Type1)();\n"
3130+
"typedef MySpace::Format_E2 (**PtrToFunPtr_Type2)();\n"
3131+
"PtrToFunPtr_Type1 t1;\n"
3132+
"PtrToFunPtr_Type2 t2;\n";
3133+
ASSERT_EQUALS("int Format_T1 ; "
3134+
"namespace MySpace "
3135+
"{ "
3136+
"int Format_T2 ; "
3137+
"} "
3138+
"int ( * * t1 ) ( ) ; "
3139+
"int ( * * t2 ) ( ) ;",
3140+
tok(code,false));
3141+
}
3142+
31233143
void simplifyTypedefShadow() { // shadow variable (#4445)
31243144
const char code[] = "typedef struct { int x; } xyz;;\n"
31253145
"void f(){\n"

0 commit comments

Comments
 (0)