Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7149,6 +7149,8 @@ class TestTokenizer : public TestFixture {
ASSERT_NO_THROW(tokenizeAndStringify("template <typename T, int N>\n" // #12659
"constexpr void f(T(&&a)[N]) {}"));

ASSERT_NO_THROW(tokenizeAndStringify("typedef struct { typedef int T; } S;")); // #12700

ignore_errout();
}

Expand Down