Skip to content

Commit 8dd1745

Browse files
committed
Fix #14125
1 parent 1c2cb0e commit 8dd1745

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

lib/tokenize.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9607,19 +9607,31 @@ void Tokenizer::simplifyCPPAttribute()
96079607
if (!head)
96089608
syntaxError(tok);
96099609

9610-
while (Token::Match(head->next(), "%name%|*|&|&&|const|static|inline|volatile"))
9611-
head = head->next();
9612-
if (Token::Match(head, "%name%") && !Token::Match(head, "auto ["))
9613-
head->isAttributeMaybeUnused(true);
9614-
else if (Token::Match(tok->previous(), "%name%") && Token::Match(tok->link(), "] [;={]")) {
9615-
tok->previous()->isAttributeMaybeUnused(true);
9610+
if (Token::simpleMatch(head, ";")) {
9611+
Token *backTok = tok;
9612+
while (backTok && Token::Match(backTok, "]|[|)")) {
9613+
if (Token::Match(backTok, "]|)"))
9614+
backTok = backTok->link();
9615+
backTok = backTok->previous();
9616+
}
9617+
if (backTok && Token::Match(backTok, "%name%")) {
9618+
backTok->isAttributeMaybeUnused(true);
9619+
}
96169620
} else {
9617-
if (Token::simpleMatch(head->next(), "[")) {
9621+
while (Token::Match(head->next(), "%name%|::|*|&|&&"))
96189622
head = head->next();
9619-
const Token *end = head->link();
9620-
for (head = head->next(); end && head != end; head = head->next()) {
9621-
if (Token::Match(head, "%name%")) {
9622-
head->isAttributeMaybeUnused(true);
9623+
if (Token::Match(head, "%name%") && !Token::Match(head, "auto ["))
9624+
head->isAttributeMaybeUnused(true);
9625+
else if (Token::Match(tok->previous(), "%name%") && Token::Match(tok->link(), "] [;={]")) {
9626+
tok->previous()->isAttributeMaybeUnused(true);
9627+
} else {
9628+
if (Token::simpleMatch(head->next(), "[")) {
9629+
head = head->next();
9630+
const Token *end = head->link();
9631+
for (head = head->next(); end && head != end; head = head->next()) {
9632+
if (Token::Match(head, "%name%")) {
9633+
head->isAttributeMaybeUnused(true);
9634+
}
96239635
}
96249636
}
96259637
}

0 commit comments

Comments
 (0)