From 95a0aa783f4234c0208987573d7980d66b9c0f84 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 3 May 2024 11:22:02 +0200 Subject: [PATCH 1/3] Update tokenize.cpp --- lib/tokenize.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 432d43f4463..35c60fc5ccf 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8727,6 +8727,10 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (tok->str() == "typedef") { for (const Token* tok2 = tok->next(); tok2 && tok2->str() != ";"; tok2 = tok2->next()) { + if (tok2->str() == "{") { + tok2 = tok2->link(); + continue; + } if (isUnevaluated(tok2)) { tok2 = tok2->linkAt(1); continue; From ebf4b7dd68a69dfbf6de7059a5353f354215f6b8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 3 May 2024 11:23:01 +0200 Subject: [PATCH 2/3] Update testtokenize.cpp --- test/testtokenize.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b07114d7f79..13969de1430 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7149,6 +7149,8 @@ class TestTokenizer : public TestFixture { ASSERT_NO_THROW(tokenizeAndStringify("template \n" // #12659 "constexpr void f(T(&&a)[N]) {}")); + ASSERT_NO_THROW(tokenizeAndStringify("typedef struct { typedef int T; } S;")); // #12700 + ignore_errout(); } From 70484d4ff193df90c74fc0dbbe42fe6dff3dccf5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 3 May 2024 11:31:01 +0200 Subject: [PATCH 3/3] Update testsimplifytypedef.cpp --- test/testsimplifytypedef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 37496dfe339..44abd19da3c 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -2516,7 +2516,7 @@ class TestSimplifyTypedef : public TestFixture { void simplifyTypedef106() { // ticket #3619 (segmentation fault) const char code[] = "typedef void f ();\ntypedef { f }"; - ASSERT_THROW_INTERNAL(tok(code), SYNTAX); + ASSERT_THROW_INTERNAL_EQUALS(tok(code), INTERNAL, "Internal error. AST cyclic dependency."); } void simplifyTypedef107() { // ticket #3963 (bad code => segmentation fault)