File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2016,7 +2016,7 @@ void Tokenizer::simplifyTypedefCpp()
2016
2016
const bool isPointerTypeCall = !inOperator && Token::Match (tok2, " %name% ( )" ) && !pointers.empty ();
2017
2017
2018
2018
// start substituting at the typedef name by replacing it with the type
2019
- const Token * const location = tok2;
2019
+ const Token* location = tok2;
2020
2020
for (Token* tok3 = typeStart; tok3 && (tok3->str () != " ;" ); tok3 = tok3->next ())
2021
2021
tok3->isSimplifiedTypedef (true );
2022
2022
if (isPointerTypeCall) {
@@ -2081,6 +2081,7 @@ void Tokenizer::simplifyTypedefCpp()
2081
2081
if (constTok && !functionPtr) {
2082
2082
tok2 = simplifyTypedefInsertToken (tok2, " const" , location);
2083
2083
constTok->deleteThis ();
2084
+ location = constTok;
2084
2085
}
2085
2086
}
2086
2087
Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ class TestSimplifyTypedef : public TestFixture {
223
223
TEST_CASE (simplifyTypedef155);
224
224
TEST_CASE (simplifyTypedef156);
225
225
TEST_CASE (simplifyTypedef157);
226
+ TEST_CASE (simplifyTypedef158);
226
227
227
228
TEST_CASE (simplifyTypedefFunction1);
228
229
TEST_CASE (simplifyTypedefFunction2); // ticket #1685
@@ -3773,6 +3774,16 @@ class TestSimplifyTypedef : public TestFixture {
3773
3774
ASSERT_EQUALS (exp , tok (code));
3774
3775
}
3775
3776
3777
+ void simplifyTypedef158 () {
3778
+ const char code[] = " void f() {\n "
3779
+ " typedef const char* const triple[3];\n "
3780
+ " static const triple data[] = { {\" a\" , \" b\" , \" c\" } };\n "
3781
+ " }\n " ;
3782
+ const char exp [] = " void f ( ) { static const char * const data [ ] [ 3 ] = { { \" a\" , \" b\" , \" c\" } } ; }" ;
3783
+ const char cur[] = " void f ( ) { static const char * const const data [ ] [ 3 ] = { { \" a\" , \" b\" , \" c\" } } ; }" ;
3784
+ TODO_ASSERT_EQUALS (exp , cur, tok (code));
3785
+ }
3786
+
3776
3787
void simplifyTypedefFunction1 () {
3777
3788
{
3778
3789
const char code[] = " typedef void (*my_func)();\n "
You can’t perform that action at this time.
0 commit comments