From bbea2ded95ed27d9f4b9d74d01b26c42c8864a97 Mon Sep 17 00:00:00 2001 From: hagantsa Date: Tue, 16 Jul 2024 15:55:37 +0300 Subject: [PATCH] [CORRECTIVE] Fix unary minus expression parsing of non-ints. Fix SystemVerilogExpressionParser test project. --- KactusAPI/expressions/SystemVerilogExpressionParser.cpp | 7 ++++++- tests/Core/tst_SystemVerilogExpressionParser.pro | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/KactusAPI/expressions/SystemVerilogExpressionParser.cpp b/KactusAPI/expressions/SystemVerilogExpressionParser.cpp index 250c59370..43f554a61 100644 --- a/KactusAPI/expressions/SystemVerilogExpressionParser.cpp +++ b/KactusAPI/expressions/SystemVerilogExpressionParser.cpp @@ -615,7 +615,12 @@ QString SystemVerilogExpressionParser::solveUnary(QStringView operation, QString } else if (operation.compare(QLatin1String("`")) == 0) { - return QString::number(~term.toLongLong() + 1); + if (!term.contains(QLatin1Char('.'))) + { + return QString::number(-term.toLongLong()); + } + + return QString::number(-term.toDouble(), 'f', precisionOf(term)); } return QStringLiteral("x"); diff --git a/tests/Core/tst_SystemVerilogExpressionParser.pro b/tests/Core/tst_SystemVerilogExpressionParser.pro index ac30095e9..6c1e1f7e3 100644 --- a/tests/Core/tst_SystemVerilogExpressionParser.pro +++ b/tests/Core/tst_SystemVerilogExpressionParser.pro @@ -16,17 +16,19 @@ TARGET = tst_SystemVerilogExpressionParser QT += core xml gui testlib CONFIG += c++11 testcase console -LIBS += -L$$PWD/../../executable/ -lKactusAPI win32:CONFIG(release, debug|release) { + LIBS += -L$$PWD/../../executable/ -lKactusAPI DESTDIR = ./release } else:win32:CONFIG(debug, debug|release) { + LIBS += -L$$PWD/../../executable/ -lKactusAPId DESTDIR = ./debug } else:unix { + LIBS += -L$$PWD/../../executable/ -lKactusAPI DESTDIR = ./release - } +} INCLUDEPATH += $$DESTDIR INCLUDEPATH += ../../