From f9058a75347bf699c452b1f6cdf637d48429b7a2 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 5 Nov 2020 18:23:32 +0100 Subject: moc: output errors and warnings in a way that matches compilers gcc, clang, and MSVC all use lowercase "warning:", "error:" and "note:". Follow that standard. Also, include a column number; just print 1, as the Symbol doesn't give us a column number, and searching backwards for a newline seems overkill. This fixes IDE integrations that parse compiler output using regular expressions. The test checks for moc output, but most tests were so far only running on Linux systems. Expand this to Unix for most tests, which then includes macOS. Change-Id: I0a6151cc0dc50e52ca72ff8048a45213aebdb3a8 Reviewed-by: Lars Knoll --- src/tools/moc/parser.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/parser.cpp b/src/tools/moc/parser.cpp index 068f75d4bd..4b67e3a99a 100644 --- a/src/tools/moc/parser.cpp +++ b/src/tools/moc/parser.cpp @@ -40,9 +40,9 @@ Symbol::LexemStore Symbol::lexemStore; static const char *error_msg = nullptr; #ifdef Q_CC_MSVC -#define ErrorFormatString "%s(%d): " +#define ErrorFormatString "%s(%d:%d): " #else -#define ErrorFormatString "%s:%d: " +#define ErrorFormatString "%s:%d:%d: " #endif void Parser::error(int rollback) { @@ -51,24 +51,24 @@ void Parser::error(int rollback) { } void Parser::error(const char *msg) { if (msg || error_msg) - fprintf(stderr, ErrorFormatString "Error: %s\n", - currentFilenames.top().constData(), symbol().lineNum, msg?msg:error_msg); + fprintf(stderr, ErrorFormatString "error: %s\n", + currentFilenames.top().constData(), symbol().lineNum, 1, msg?msg:error_msg); else - fprintf(stderr, ErrorFormatString "Parse error at \"%s\"\n", - currentFilenames.top().constData(), symbol().lineNum, symbol().lexem().data()); + fprintf(stderr, ErrorFormatString "error: Parse error at \"%s\"\n", + currentFilenames.top().constData(), symbol().lineNum, 1, symbol().lexem().data()); exit(EXIT_FAILURE); } void Parser::warning(const char *msg) { if (displayWarnings && msg) - fprintf(stderr, ErrorFormatString "Warning: %s\n", - currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), msg); + fprintf(stderr, ErrorFormatString "warning: %s\n", + currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), 1, msg); } void Parser::note(const char *msg) { if (displayNotes && msg) - fprintf(stderr, ErrorFormatString "Note: %s\n", - currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), msg); + fprintf(stderr, ErrorFormatString "note: %s\n", + currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), 1, msg); } QT_END_NAMESPACE -- cgit v1.2.3