Skip to content

Commit 2e19539

Browse files
Fix #14977 internalError for valid typedef (operator=) (#8798)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 777a112 commit 2e19539

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
@@ -3887,6 +3887,9 @@ class TestSimplifyTypedef : public TestFixture {
38873887

38883888
const char code3[] = "typedef struct S { S() {} } S;"; // #14971
38893889
ASSERT_EQUALS("struct S { S ( ) { } } ;", tok(code3));
3890+
3891+
const char code4[] = "typedef struct S { S& operator=(const S&) = delete; } S;"; // #14977
3892+
ASSERT_EQUALS("struct S { S & operator= ( const S & ) = delete ; } ;", tok(code4));
38903893
}
38913894

38923895
void simplifyTypedefFunction1() {

0 commit comments

Comments
 (0)