Skip to content

Commit aab3e79

Browse files
committed
polyspace: compute lineEnd in long long, split catch clauses
1 parent 5256aa3 commit aab3e79

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎lib/suppressions.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ std::list<SuppressionList::Suppression> polyspace::Parser::parse(const std::stri
886886
if (rangeValue > 0) {
887887
suppr.type = SuppressionList::Type::block;
888888
suppr.lineBegin = line;
889-
suppr.lineEnd = (rangeValue > std::numeric_limits<int>::max() - line) ? std::numeric_limits<int>::max() : (line + rangeValue);
889+
suppr.lineEnd = static_cast<int>(std::min<long long>(std::numeric_limits<int>::max(), static_cast<long long>(line) + rangeValue));
890890
}
891891
else if (polyspaceKind == polyspace::CommentKind::Regular)
892892
suppr.type = SuppressionList::Type::unique;
@@ -922,7 +922,9 @@ int polyspace::Parser::parseRange(const std::string& comment, std::string::size_
922922
int ret = std::stoi(range);
923923
pos = endpos;
924924
return ret;
925-
} catch (const std::invalid_argument &) {} catch (const std::out_of_range &) {}
925+
} catch (const std::invalid_argument &) {
926+
} catch (const std::out_of_range &) {
927+
}
926928
return 0;
927929
}
928930

‎test/testsuppressions.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,12 @@ class TestSuppressions : public TestFixture {
24072407
{ "/* polyspace +2147483647 MISRA2012 : 2.7 */", 2 },
24082408
{ { "premium-misra-c-2012-2.7", 2, "", SuppressionList::Type::block, 2, std::numeric_limits<int>::max() } }
24092409
);
2410+
2411+
testPolyspaceSuppression(
2412+
"", "--misra-c-2012",
2413+
{ "/* polyspace +5 MISRA2012 : 2.7 */", -1 },
2414+
{ { "premium-misra-c-2012-2.7", -1, "", SuppressionList::Type::block, -1, 4 } }
2415+
);
24102416
}
24112417

24122418
void polyspaceBlock() const {

0 commit comments

Comments
 (0)