diff options
Diffstat (limited to 'src/tools/qlalr/cppgenerator.cpp')
-rw-r--r-- | src/tools/qlalr/cppgenerator.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index a41aa87835..c859df366d 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -10,6 +10,7 @@ #include <QtCore/qtextstream.h> #include <QtCore/qfile.h> #include <QtCore/qmap.h> +#include <QtCore/private/qconfig_p.h> #include <iterator> @@ -42,7 +43,7 @@ void generateList(const QList<int> &list, QTextStream &out) QString CppGenerator::copyrightHeader() const { return - "// Copyright (C) 2016 The Qt Company Ltd.\n" + "// " QT_COPYRIGHT "\n" "// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0\n" "\n"_L1; } @@ -192,7 +193,15 @@ void CppGenerator::operator () () { if (shift_reduce_conflict_count != grammar.expected_shift_reduce || reduce_reduce_conflict_count != grammar.expected_reduce_reduce) - qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl; + { + qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl; + if (warnings_are_errors) + { + qerr() << "qlalr: error: warning occurred, treating as error due to " + "--exit-on-warn." << Qt::endl; + exit(2); + } + } if (verbose) qout() << Qt::endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl @@ -214,12 +223,20 @@ void CppGenerator::operator () () } auto rule = grammar.rules.begin(); - for (int i = 0; i < used_rules.count (); ++i, ++rule) + for (int i = 0; i < used_rules.size(); ++i, ++rule) { if (! used_rules.testBit (i)) { if (rule != grammar.goal) - qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl; + { + qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl; + if (warnings_are_errors) + { + qerr() << "qlalr: error: warning occurred, treating as error due to " + "--exit-on-warn." << Qt::endl; + exit(2); + } + } } } @@ -413,7 +430,7 @@ void CppGenerator::generateDecl (QTextStream &out) << "public:" << Qt::endl << " enum VariousConstants {" << Qt::endl; - for (const Name &t : qAsConst(grammar.terminals)) + for (const Name &t : std::as_const(grammar.terminals)) { QString name = *t; int value = std::distance (grammar.names.begin (), t); |