Skip to content

Commit a309a70

Browse files
committed
Fix #14977 internalError for valid typedef (operator=)
1 parent 7d48e00 commit a309a70

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,12 @@ namespace {
572572
++nBraces;
573573
else if (tok->str() == "}")
574574
--nBraces;
575+
if (nBraces > 0)
576+
continue;
575577
if (tok == mNameToken)
576578
continue;
577579
if (tok->str() != mNameToken->str())
578580
continue;
579-
if (nBraces > 0 && Token::Match(tok->next(), "[;(]"))
580-
continue;
581581
if (Token::Match(tok->previous(), "struct|class|enum|union"))
582582
continue;
583583
throw InternalError(tok, "recursive typedef encountered");

test/testsimplifytypedef.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,9 @@ class TestSimplifyTypedef : public TestFixture {
38853885

38863886
const char code3[] = "typedef struct S { S() {} } S;"; // #14971
38873887
ASSERT_EQUALS("struct S { S ( ) { } } ;", tok(code3));
3888+
3889+
const char code4[] = "typedef struct S { S& operator=(const S&) = delete; } S;"; // #14977
3890+
ASSERT_EQUALS("struct S { S & operator= ( const S & ) = delete ; } ;", tok(code4));
38883891
}
38893892

38903893
void simplifyTypedefFunction1() {

0 commit comments

Comments
 (0)