diff --git a/outputview/outputformats.h b/outputview/outputformats.h --- a/outputview/outputformats.h +++ b/outputview/outputformats.h @@ -40,6 +40,9 @@ int textGroup; QString compiler; + // Returns the column number starting with 0 as the first column + // If no match was found for columns or if index was not valid + // (i.e. less than zero) - 0 is returned. int columnNumber(const QRegularExpressionMatch& match) const; }; diff --git a/outputview/outputformats.cpp b/outputview/outputformats.cpp --- a/outputview/outputformats.cpp +++ b/outputview/outputformats.cpp @@ -49,7 +49,7 @@ int ErrorFormat::columnNumber(const QRegularExpressionMatch& match) const { - return columnGroup >= 0 ? match.captured( columnGroup ).toInt() - 1 : 0; + return columnGroup < 0 ? 0 : std::max(match.captured(columnGroup).toInt() - 1, 0); } } diff --git a/outputview/tests/test_filteringstrategy.cpp b/outputview/tests/test_filteringstrategy.cpp --- a/outputview/tests/test_filteringstrategy.cpp +++ b/outputview/tests/test_filteringstrategy.cpp @@ -447,6 +447,9 @@ QTest::newRow("gcc-no-col") << "/path/to/file.cpp:123: error ..." << "/path/to/file.cpp" << 122 << 0 << FilteredItem::ErrorItem; + QTest::newRow("gcc-app-gives-invalid-column") + << "/path/to/file.h:60:0:\ +warning: \"SOME_MACRO\" redefined" << "/path/to/file.h" << 59 << 0 << FilteredItem::WarningItem; QTest::newRow("fortcom") << "fortcom: Error: Ogive8.f90, line 123: ..." << QString(projectPath() + "/Ogive8.f90") << 122 << 0 << FilteredItem::ErrorItem;