@@ -88,8 +88,10 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
8888 const std::string::size_type pos1 = comment.find_first_not_of (" /* \t " );
8989 if (pos1 == std::string::npos)
9090 return false ;
91- if (pos1 + cppchecksuppress.size () >= comment.size ())
91+ if (pos1 + cppchecksuppress.size () >= comment.size ()) {
92+ bad.emplace_back (tok->location .file (), tok->location .line , 0 , " suppression without error ID" );
9293 return false ;
94+ }
9395 if (comment.substr (pos1, cppchecksuppress.size ()) != cppchecksuppress)
9496 return false ;
9597
@@ -98,8 +100,10 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
98100
99101 // skip spaces after "cppcheck-suppress" and its possible prefix
100102 const std::string::size_type pos2 = comment.find_first_not_of (' ' , posEndComment);
101- if (pos2 == std::string::npos)
103+ if (pos2 == std::string::npos) {
104+ bad.emplace_back (tok->location .file (), tok->location .line , 0 , " suppression without error ID" );
102105 return false ;
106+ }
103107
104108 SuppressionList::Type errorType = SuppressionList::Type::unique;
105109
@@ -142,9 +146,11 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
142146 s.lineNumber = tok->location .line ;
143147 }
144148
149+ // TODO: unreachable?
145150 if (!errmsg.empty ())
146151 bad.emplace_back (tok->location .file (), tok->location .line , tok->location .col , std::move (errmsg));
147152
153+ // TODO: report ones without ID - unreachable?
148154 std::copy_if (suppressions.cbegin (), suppressions.cend (), std::back_inserter (inlineSuppressions), [](const SuppressionList::Suppression& s) {
149155 return !s.errorId .empty ();
150156 });
@@ -159,9 +165,11 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
159165 s.type = errorType;
160166 s.lineNumber = tok->location .line ;
161167
168+ // TODO: report when no ID - unreachable?
162169 if (!s.errorId .empty ())
163170 inlineSuppressions.push_back (std::move (s));
164171
172+ // TODO: unreachable?
165173 if (!errmsg.empty ())
166174 bad.emplace_back (tok->location .file (), tok->location .line , tok->location .col , std::move (errmsg));
167175 }
0 commit comments