From e783e4c4e25bbd9e04408f305284916679d1a30f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 28 Sep 2020 18:48:01 -0700 Subject: [PATCH] base: Add some error handling to compiler.hh. Rather than just leaving some macros undefined if none of the scenarios we checked for match, we should report an error so it's clear what happened. Otherwise the places the macros are used will just not compile properly, or worse will silently not work correctly. Change-Id: Ie010d6b6d1b6a1496a45d9ebc0d75d1c804df12f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35275 Reviewed-by: Daniel Carvalho Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- src/base/compiler.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base/compiler.hh b/src/base/compiler.hh index ee9a224b1..ead1507fd 100644 --- a/src/base/compiler.hh +++ b/src/base/compiler.hh @@ -76,6 +76,8 @@ // gcc and clang support a custom attribute which is essentially the same // thing. # define M5_VAR_USED [[gnu::unused]] +#else +# error "Don't know what to do for your compiler." #endif @@ -106,6 +108,8 @@ // we can't do that with direct substitution. # define M5_LIKELY(cond) __builtin_expect(!!(cond), 1) # define M5_UNLIKELY(cond) __builtin_expect(!!(cond), 0) +#else +# error "Don't know what to do for your compiler." #endif // When a member variable may be unused, mark it with M5_CLASS_VAR_USED. This -- 2.30.2