Skip to content

Commit e755fdb

Browse files
Followup fix for #14126 crash in Tokenizer::simplifyCPPAttribute() (#7863)
1 parent ec142c9 commit e755fdb

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/tokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9550,6 +9550,8 @@ void Tokenizer::simplifyCPPAttribute()
95509550
Token* head = skipCPPOrAlignAttribute(tok)->next();
95519551
while (isCPPAttribute(head) || isAlignAttribute(head))
95529552
head = skipCPPOrAlignAttribute(head)->next();
9553+
if (!head)
9554+
syntaxError(tok);
95539555
head->isAttributeUnused(true);
95549556
} else if (Token::Match(tok->previous(), ") [ [ expects|ensures|assert default|audit|axiom| : %name% <|<=|>|>= %num% ] ]")) {
95559557
const Token *vartok = tok->tokAt(4);

test/testgarbage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,7 @@ class TestGarbage : public TestFixture {
17711771
}
17721772
void garbageCode229() { // #14126
17731773
ASSERT_THROW_INTERNAL(checkCode("void f() {} [[maybe_unused]]"), SYNTAX);
1774+
ASSERT_THROW_INTERNAL(checkCode("void f() {} [[unused]]"), SYNTAX);
17741775
}
17751776

17761777

0 commit comments

Comments
 (0)