From a309a70bb419579f10d68e8e9a8459e83762b0b4 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Mon, 17 Aug 2026 11:26:34 +0200 Subject: [PATCH] Fix #14977 internalError for valid typedef (operator=) --- lib/tokenize.cpp | 4 ++-- test/testsimplifytypedef.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 27be2e544a2..2d937c6a210 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -572,12 +572,12 @@ namespace { ++nBraces; else if (tok->str() == "}") --nBraces; + if (nBraces > 0) + continue; if (tok == mNameToken) continue; if (tok->str() != mNameToken->str()) continue; - if (nBraces > 0 && Token::Match(tok->next(), "[;(]")) - continue; if (Token::Match(tok->previous(), "struct|class|enum|union")) continue; throw InternalError(tok, "recursive typedef encountered"); diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 78d7bd25f3d..dbf913c63a4 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -3885,6 +3885,9 @@ class TestSimplifyTypedef : public TestFixture { const char code3[] = "typedef struct S { S() {} } S;"; // #14971 ASSERT_EQUALS("struct S { S ( ) { } } ;", tok(code3)); + + const char code4[] = "typedef struct S { S& operator=(const S&) = delete; } S;"; // #14977 + ASSERT_EQUALS("struct S { S & operator= ( const S & ) = delete ; } ;", tok(code4)); } void simplifyTypedefFunction1() {