diff --git a/outputview/outputformats.h b/outputview/outputformats.h --- a/outputview/outputformats.h +++ b/outputview/outputformats.h @@ -40,6 +40,8 @@ int textGroup; QString compiler; + // Returns the column number starting with 0 as the first column + // If no valid columns index was found in the match is found - 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,9 @@ int ErrorFormat::columnNumber(const QRegularExpressionMatch& match) const { - return columnGroup >= 0 ? match.captured( columnGroup ).toInt() - 1 : 0; + if(columnGroup < 0) return 0; + int columnNumberFromApp = match.captured( columnGroup ).toInt() - 1; + return columnNumberFromApp >= 0 ? columnNumberFromApp : 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;