From c4b85d5f9854abeee6d1dbe15ae65a7a1aada6b2 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Thu, 18 May 2017 15:11:23 +0100 Subject: [PATCH] base, sim, arch: Fix clang 5.0 warnings Compiling gem5 with recent version of clang (4 and 5) triggers warnings that are treated as errors: * Global templatized static functions result in a warning if they are not used. These should either be declared as static inline or without the static identifier to avoid the warning. * Some templatized classes contain static variables. The instantiated versions of these variables / templates need to be explicitly declared to avoid a compiler warning. Change-Id: Ie8261144836e94ebab7ea04ccccb90927672c257 Signed-off-by: Andreas Sandberg Reviewed-by: Curtis Dunham Reviewed-on: https://gem5-review.googlesource.com/3420 Reviewed-by: Jason Lowe-Power --- src/arch/arm/faults.hh | 3 +- src/arch/arm/insts/vfp.hh | 2 +- src/arch/arm/isa/insts/fp.isa | 8 ++--- src/arch/hsail/insts/decl.hh | 21 ++++++++++++ src/arch/mips/faults.hh | 24 +++++++++++++ src/arch/sparc/faults.hh | 64 +++++++++++++++++++++++++++++++++++ src/base/circlebuf.hh | 8 ++--- src/sim/syscall_emul.hh | 10 +++--- 8 files changed, 125 insertions(+), 15 deletions(-) diff --git a/src/arch/arm/faults.hh b/src/arch/arm/faults.hh index ab4c67552..6e7c92cf6 100644 --- a/src/arch/arm/faults.hh +++ b/src/arch/arm/faults.hh @@ -567,7 +567,8 @@ class IllegalInstSetStateFault : public ArmFaultVals }; /* - * Explicitly declare template static member variables avoid warnings in some clang versions + * Explicitly declare template static member variables to avoid warnings + * in some clang versions */ template<> ArmFault::FaultVals ArmFaultVals::vals; template<> ArmFault::FaultVals ArmFaultVals::vals; diff --git a/src/arch/arm/insts/vfp.hh b/src/arch/arm/insts/vfp.hh index de0c62161..caa22376e 100644 --- a/src/arch/arm/insts/vfp.hh +++ b/src/arch/arm/insts/vfp.hh @@ -201,7 +201,7 @@ bitsToFp(uint64_t bits, double junk) } template -static bool +static inline bool isSnan(fpType val) { const bool single = (sizeof(fpType) == sizeof(float)); diff --git a/src/arch/arm/isa/insts/fp.isa b/src/arch/arm/isa/insts/fp.isa index 0f10a05af..dc2f30701 100644 --- a/src/arch/arm/isa/insts/fp.isa +++ b/src/arch/arm/isa/insts/fp.isa @@ -65,7 +65,7 @@ class VfpMacroRegRegOp : public VfpMacroOp }; template -static StaticInstPtr +StaticInstPtr decodeVfpRegRegOp(ExtMachInst machInst, IntRegIndex dest, IntRegIndex op1, bool wide) { @@ -101,7 +101,7 @@ class VfpMacroRegImmOp : public VfpMacroOp }; template -static StaticInstPtr +StaticInstPtr decodeVfpRegImmOp(ExtMachInst machInst, IntRegIndex dest, uint64_t imm, bool wide) { @@ -137,7 +137,7 @@ class VfpMacroRegRegImmOp : public VfpMacroOp }; template -static StaticInstPtr +StaticInstPtr decodeVfpRegRegImmOp(ExtMachInst machInst, IntRegIndex dest, IntRegIndex op1, uint64_t imm, bool wide) { @@ -173,7 +173,7 @@ class VfpMacroRegRegRegOp : public VfpMacroOp }; template -static StaticInstPtr +StaticInstPtr decodeVfpRegRegRegOp(ExtMachInst machInst, IntRegIndex dest, IntRegIndex op1, IntRegIndex op2, bool wide) { diff --git a/src/arch/hsail/insts/decl.hh b/src/arch/hsail/insts/decl.hh index f84cb61e9..3132a425a 100644 --- a/src/arch/hsail/insts/decl.hh +++ b/src/arch/hsail/insts/decl.hh @@ -1272,6 +1272,27 @@ namespace HsailISA template T heynot(T arg) { return ~arg; } template<> inline bool heynot(bool arg) { return !arg; } + + + /* Explicitly declare template static member variables to avoid + * warnings in some clang versions + */ + template<> const char *B1::label; + template<> const char *B8::label; + template<> const char *B16::label; + template<> const char *B32::label; + template<> const char *B64::label; + template<> const char *S8::label; + template<> const char *S16::label; + template<> const char *S32::label; + template<> const char *S64::label; + template<> const char *U8::label; + template<> const char *U16::label; + template<> const char *U32::label; + template<> const char *U64::label; + template<> const char *F32::label; + template<> const char *F64::label; + } // namespace HsailISA #endif // __ARCH_HSAIL_INSTS_DECL_HH__ diff --git a/src/arch/mips/faults.hh b/src/arch/mips/faults.hh index 1ec726d17..dcce764ca 100644 --- a/src/arch/mips/faults.hh +++ b/src/arch/mips/faults.hh @@ -303,6 +303,30 @@ class TlbModifiedFault : public TlbFault ExcCode code() const { return MipsFault::code(); } }; +/* + * Explicitly declare template static member variables to avoid warnings + * in some clang versions + */ +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; +template<> MipsFaultBase::FaultVals MipsFault::vals; + + + } // namespace MipsISA #endif // __MIPS_FAULTS_HH__ diff --git a/src/arch/sparc/faults.hh b/src/arch/sparc/faults.hh index 9d5f7e01d..42c8b7149 100644 --- a/src/arch/sparc/faults.hh +++ b/src/arch/sparc/faults.hh @@ -276,6 +276,70 @@ class TrapInstruction : public EnumeratedFault StaticInst::nullStaticInstPtr); }; +/* + * Explicitly declare template static member variables to avoid warnings + * in some clang versions + */ +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals + SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> + SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; +template<> SparcFaultBase::FaultVals SparcFault::vals; + + void enterREDState(ThreadContext *tc); void doREDFault(ThreadContext *tc, TrapType tt); diff --git a/src/base/circlebuf.hh b/src/base/circlebuf.hh index 2ab14e269..bf6f9e263 100644 --- a/src/base/circlebuf.hh +++ b/src/base/circlebuf.hh @@ -247,7 +247,7 @@ class Fifo template -static void +void arrayParamOut(CheckpointOut &cp, const std::string &name, const CircleBuf ¶m) { @@ -257,7 +257,7 @@ arrayParamOut(CheckpointOut &cp, const std::string &name, } template -static void +void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf ¶m) { @@ -269,7 +269,7 @@ arrayParamIn(CheckpointIn &cp, const std::string &name, } template -static void +void arrayParamOut(CheckpointOut &cp, const std::string &name, const Fifo ¶m) { @@ -279,7 +279,7 @@ arrayParamOut(CheckpointOut &cp, const std::string &name, } template -static void +void arrayParamIn(CheckpointIn &cp, const std::string &name, Fifo ¶m) { diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 53c053f05..7efd7c7e6 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -429,7 +429,7 @@ getElapsedTimeNano(T1 &sec, T2 &nsec) //// memory space. Used by stat(), fstat(), and lstat(). template -static void +void convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false) { using namespace TheISA; @@ -478,7 +478,7 @@ convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false) // Same for stat64 template -static void +void convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false) { using namespace TheISA; @@ -500,7 +500,7 @@ convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false) // Here are a couple of convenience functions template -static void +void copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, hst_stat *host, bool fakeTTY = false) { @@ -511,7 +511,7 @@ copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, } template -static void +void copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr, hst_stat64 *host, bool fakeTTY = false) { @@ -522,7 +522,7 @@ copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr, } template -static void +void copyOutStatfsBuf(SETranslatingPortProxy &mem, Addr addr, hst_statfs *host) { -- 2.30.2