From 4fdfd98230e780aeb068e3740742c7bff28fb859 Mon Sep 17 00:00:00 2001 From: Jason Lowe-Power Date: Thu, 2 Aug 2018 18:07:51 -0700 Subject: [PATCH] misc: Appease GCC 8 GCC 8 adds a number of new warnings to -Wall which generate errors. - Fix memset to 0 for structs by adding casts. - Fix cast with const when the const was ignored. - Fix catch a polymorphic type by value We now compile with GCC 8! Change-Id: Iab70ce11190eee67608fc25c0bedff170152b153 Signed-off-by: Jason Lowe-Power Reviewed-on: https://gem5-review.googlesource.com/11949 Reviewed-by: Daniel Carvalho Reviewed-by: Andreas Sandberg --- src/arch/x86/decoder.hh | 2 +- src/arch/x86/types.hh | 4 ++++ src/base/bitunion.hh | 4 ++-- src/cpu/testers/traffic_gen/pygen.cc | 2 +- src/dev/storage/ide_ctrl.cc | 2 +- src/dev/storage/ide_ctrl.hh | 4 ++++ 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index 3630ea8c8..c0b30b5e8 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -239,7 +239,7 @@ class Decoder outOfBytes(true), instDone(false), state(ResetState) { - memset(&emi, 0, sizeof(emi)); + emi.reset(); mode = LongMode; submode = SixtyFourBitMode; emi.mode.mode = mode; diff --git a/src/arch/x86/types.hh b/src/arch/x86/types.hh index 6e1b1cf2f..f2b064650 100644 --- a/src/arch/x86/types.hh +++ b/src/arch/x86/types.hh @@ -199,6 +199,10 @@ namespace X86ISA //The intermediate structure used by the x86 decoder. struct ExtMachInst { + void reset() { + memset(static_cast(this), 0, sizeof(*this)); + } + //Prefixes LegacyPrefixVector legacy; Rex rex; diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh index 49a956eec..1a32991a8 100644 --- a/src/base/bitunion.hh +++ b/src/base/bitunion.hh @@ -435,7 +435,7 @@ namespace BitfieldBackend inline std::ostream & bitfieldBackendPrinter(std::ostream &os, const char &t) { - os << (const int)t; + os << (int)t; return os; } @@ -443,7 +443,7 @@ namespace BitfieldBackend inline std::ostream & bitfieldBackendPrinter(std::ostream &os, const unsigned char &t) { - os << (const unsigned int)t; + os << (unsigned int)t; return os; } } diff --git a/src/cpu/testers/traffic_gen/pygen.cc b/src/cpu/testers/traffic_gen/pygen.cc index ce1d59130..9ce2fbf83 100644 --- a/src/cpu/testers/traffic_gen/pygen.cc +++ b/src/cpu/testers/traffic_gen/pygen.cc @@ -74,7 +74,7 @@ PyTrafficGen::nextGenerator() metaGenerator->cast>(); metaGenerator++; return gen; - } catch (py::cast_error) { + } catch (py::cast_error&) { fatal("Meta generator didn't return a valid trace generator\n"); } } diff --git a/src/dev/storage/ide_ctrl.cc b/src/dev/storage/ide_ctrl.cc index d1c9f7d73..12d606bee 100644 --- a/src/dev/storage/ide_ctrl.cc +++ b/src/dev/storage/ide_ctrl.cc @@ -83,7 +83,7 @@ IdeController::Channel::Channel( cmdAddr(0), cmdSize(_cmdSize), ctrlAddr(0), ctrlSize(_ctrlSize), master(NULL), slave(NULL), selected(NULL) { - memset(&bmiRegs, 0, sizeof(bmiRegs)); + bmiRegs.reset(); bmiRegs.status.dmaCap0 = 1; bmiRegs.status.dmaCap1 = 1; } diff --git a/src/dev/storage/ide_ctrl.hh b/src/dev/storage/ide_ctrl.hh index 94a9c65e5..24d3da02a 100644 --- a/src/dev/storage/ide_ctrl.hh +++ b/src/dev/storage/ide_ctrl.hh @@ -81,6 +81,10 @@ class IdeController : public PciDevice /** Registers used for bus master interface */ struct BMIRegs { + void reset() { + memset(static_cast(this), 0, sizeof(*this)); + } + BMICommandReg command; uint8_t reserved0; BMIStatusReg status; -- 2.30.2