From a5506270bc42a950d94a05878d8adfc15cefb464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 5 Jan 2018 16:39:31 +0100 Subject: Fix fall trough warning of gcc 7+ --- qtmips_machine/alu.cpp | 5 +++-- qtmips_machine/qtmips_machine.pro | 3 ++- qtmips_machine/utils.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 qtmips_machine/utils.h (limited to 'qtmips_machine') diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp index 2d5783d..0d40bf0 100644 --- a/qtmips_machine/alu.cpp +++ b/qtmips_machine/alu.cpp @@ -1,5 +1,6 @@ #include "alu.h" #include "qtmipsexception.h" +#include "utils.h" using namespace machine; @@ -42,13 +43,13 @@ std::uint32_t machine::alu_operate(enum AluOp operation, std::uint32_t s, std::u case ALU_OP_ADD: if (s > (0xFFFFFFFF - t)) throw QTMIPS_EXCEPTION(Overflow, "ADD operation overflow/underflow", QString::number(s) + QString(" + ") + QString::number(t)); - // Intentional falltrough + FALLTROUGH case ALU_OP_ADDU: return s + t; case ALU_OP_SUB: if (s < t) throw QTMIPS_EXCEPTION(Overflow, "SUB operation overflow/underflow", QString::number(s) + QString(" - ") + QString::number(t)); - // Intentional falltrough + FALLTROUGH case ALU_OP_SUBU: return s - t; case ALU_OP_AND: diff --git a/qtmips_machine/qtmips_machine.pro b/qtmips_machine/qtmips_machine.pro index ff5cc3f..94d1a26 100644 --- a/qtmips_machine/qtmips_machine.pro +++ b/qtmips_machine/qtmips_machine.pro @@ -34,4 +34,5 @@ HEADERS += \ programloader.h \ cache.h \ alu.h \ - machineconfig.h + machineconfig.h \ + utils.h diff --git a/qtmips_machine/utils.h b/qtmips_machine/utils.h new file mode 100644 index 0000000..7d30364 --- /dev/null +++ b/qtmips_machine/utils.h @@ -0,0 +1,10 @@ +#ifndef UTILS_H +#define UTILS_H + +#if __GNUC__ >= 7 +#define FALLTROUGH __attribute__((fallthrough)); +#else +#define FALLTROUGH +#endif + +#endif // UTILS_H -- cgit v1.2.3