File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -566,11 +566,18 @@ namespace {
566566 const auto checkForRecursion = [this ]() {
567567 if (Token::Match (mTypedefToken , " typedef %name% %name% ;" ))
568568 return ;
569+ int nBraces = 0 ;
569570 for (const Token *tok = mTypedefToken ; tok != mEndToken ; tok = tok->next ()) {
571+ if (tok->str () == " {" )
572+ ++nBraces;
573+ else if (tok->str () == " }" )
574+ --nBraces;
570575 if (tok == mNameToken )
571576 continue ;
572577 if (tok->str () != mNameToken ->str ())
573578 continue ;
579+ if (nBraces > 0 && Token::simpleMatch (tok->next (), " ;" ))
580+ continue ;
574581 if (Token::Match (tok->previous (), " struct|class|enum|union" ))
575582 continue ;
576583 throw InternalError (tok, " recursive typedef encountered" );
Original file line number Diff line number Diff line change @@ -3879,6 +3879,9 @@ class TestSimplifyTypedef : public TestFixture {
38793879 void simplifyTypedef164 () {
38803880 const char code[] = " typedef struct D{x;}y y;" ;
38813881 ASSERT_THROW_INTERNAL (tok (code), INTERNAL );
3882+
3883+ const char code2[] = " typedef struct { int t; } t;" ; // #14966
3884+ ASSERT_EQUALS (" struct t { int t ; } ;" , tok (code2));
38823885 }
38833886
38843887 void simplifyTypedefFunction1 () {
You can’t perform that action at this time.
0 commit comments