Skip to content

Commit d0ae85d

Browse files
Update tokenize.cpp
1 parent 5799d47 commit d0ae85d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/tokenize.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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");

0 commit comments

Comments
 (0)