Tokenizer::simplifyTypedef: Add test that #5191 is fixed (function pointer)

This commit is contained in:
Robert Reif 2014-12-04 05:43:58 +01:00 committed by Daniel Marjamäki
parent e3892a95b5
commit c5bfd21d48
1 changed files with 20 additions and 0 deletions

View File

@ -155,6 +155,7 @@ private:
TEST_CASE(simplifyTypedefFunction7);
TEST_CASE(simplifyTypedefFunction8);
TEST_CASE(simplifyTypedefFunction9);
TEST_CASE(simplifyTypedefFunction10); // #5191
TEST_CASE(simplifyTypedefShadow); // #4445 - shadow variable
}
@ -3120,6 +3121,25 @@ private:
}
}
void simplifyTypedefFunction10() {
const char code[] = "enum Format_E1 { FORMAT11 FORMAT12 } Format_T1;\n"
"namespace MySpace {\n"
" enum Format_E2 { FORMAT21 FORMAT22 } Format_T2;\n"
"}\n"
"typedef Format_E1 (**PtrToFunPtr_Type1)();\n"
"typedef MySpace::Format_E2 (**PtrToFunPtr_Type2)();\n"
"PtrToFunPtr_Type1 t1;\n"
"PtrToFunPtr_Type2 t2;\n";
ASSERT_EQUALS("int Format_T1 ; "
"namespace MySpace "
"{ "
"int Format_T2 ; "
"} "
"int ( * * t1 ) ( ) ; "
"int ( * * t2 ) ( ) ;",
tok(code,false));
}
void simplifyTypedefShadow() { // shadow variable (#4445)
const char code[] = "typedef struct { int x; } xyz;;\n"
"void f(){\n"