File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2080,8 +2080,8 @@ void Tokenizer::simplifyTypedefCpp()
20802080 // cppcheck-suppress useStlAlgorithm
20812081 tok2 = simplifyTypedefInsertToken (tok2, p, location);
20822082 if (constTok) {
2083- constTok->deleteThis ();
20842083 tok2 = simplifyTypedefInsertToken (tok2, " const" , location);
2084+ constTok->deleteThis ();
20852085 }
20862086 }
20872087
Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ class TestSimplifyTypedef : public TestFixture {
245245
246246 TEST_CASE (simplifyTypedefTokenColumn1);
247247 TEST_CASE (simplifyTypedefTokenColumn2);
248+ TEST_CASE (simplifyTypedefTokenColumn3);
248249
249250 TEST_CASE (typedefInfo1);
250251
@@ -4493,6 +4494,14 @@ class TestSimplifyTypedef : public TestFixture {
44934494 ASSERT_EQUALS (5 , type->column ());
44944495 }
44954496
4497+ void simplifyTypedefTokenColumn3 () { // #13368
4498+ const char code[] = " typedef struct S_ {} S;\n "
4499+ " typedef S* P;\n "
4500+ " void f(const P p);\n " ;
4501+ ASSERT_EQUALS (" struct S_ { } ; void f ( struct S_ * const p ) ;" , // don't crash
4502+ tok (code));
4503+ }
4504+
44964505 void typedefInfo1 () {
44974506 const std::string xml = dumpTypedefInfo (" typedef int A;\n A x;" );
44984507 ASSERT_EQUALS (" <typedef-info>\n "
You can’t perform that action at this time.
0 commit comments