Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed May 1, 2024
1 parent b5604e9 commit edc7c1b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8427,7 +8427,6 @@ void Tokenizer::findGarbageCode() const
"goto",
"if",
"return",
"static",
"switch",
"throw",
"typedef",
Expand Down Expand Up @@ -8720,6 +8719,12 @@ void Tokenizer::findGarbageCode() const
}
}
}
if (tok->str() == "typedef") {
for (const Token* tok2 = tok->next(); tok2 && tok2->str() != ";"; tok2 = tok2->next()) {
if (!tok2->next() || tok2->isControlFlowKeyword() || Token::Match(tok2, "typedef|static|."))
syntaxError(tok);
}
}
}

// ternary operator without :
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{for(typedef U typedef{};);}
1 change: 0 additions & 1 deletion test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,6 @@ class TestGarbage : public TestFixture {

void garbageCode74() { // #6751
ASSERT_THROW_INTERNAL(checkCode("_lenraw(const char* digits) { } typedef decltype(sizeof(0)) { } operator"), SYNTAX);
ignore_errout(); // we do not care about the output
}

void garbageCode76() { // #6754
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_EQUALS(tok(code), INTERNAL, "Internal error. AST cyclic dependency.");
ASSERT_THROW_INTERNAL(tok(code), SYNTAX);
}

void simplifyTypedef107() { // ticket #3963 (bad code => segmentation fault)
Expand Down

0 comments on commit edc7c1b

Please sign in to comment.