From 0426fc120e09438eb319b349fc422d8223f77aec Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 9 Nov 2018 20:54:23 +0300 Subject: [PATCH] Workaround '#error' cppcheck messages in backgraph and private headers * backgraph.c [!DBG_HDRS_ALL || ALIGNMENT!=CPP_WORDSZ/8]: Skip #error directive if CPPCHECK. * include/private/dbg_mlc.h [(KEEP_BACK_PTRS || MAKE_BACK_GRAPH) && SHORT_DBG_HDRS]: Likewise. * include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC && (!AO_HAVE_load || !AO_HAVE_store)]: Likewise. * include/private/gc_hdrs.h [CPP_WORDSZ!=32 && CPP_WORDSZ<36]: Likewise. * include/private/gc_priv.h [HBLKSIZE]: Likewise. * include/private/gcconfig.h [SPARC && LINUX && !__ELF__]: Likewise. * include/private/gcconfig.h [I386 && (__LP64__ || _WIN64)]: Likewise. * include/private/gcconfig.h [IA64 && HPUX && !_ILP32 && !_LP64]: Likewise. * include/private/gcconfig.h [CPP_WORDSZ!=32 && CPP_WORDSZ!=64]: Likewise. --- backgraph.c | 3 ++- include/private/dbg_mlc.h | 2 +- include/private/gc_atomic_ops.h | 2 +- include/private/gc_hdrs.h | 2 +- include/private/gc_priv.h | 4 ++-- include/private/gcconfig.h | 16 +++++++--------- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/backgraph.c b/backgraph.c index d43d170..8ea4251 100644 --- a/backgraph.c +++ b/backgraph.c @@ -32,7 +32,8 @@ /* #include */ -#if !defined(DBG_HDRS_ALL) || (ALIGNMENT != CPP_WORDSZ/8) /* || !defined(UNIX_LIKE) */ +#if (!defined(DBG_HDRS_ALL) || (ALIGNMENT != CPP_WORDSZ/8) \ + /* || !defined(UNIX_LIKE) */) && !defined(CPPCHECK) # error The configuration does not support MAKE_BACK_GRAPH #endif diff --git a/include/private/dbg_mlc.h b/include/private/dbg_mlc.h index b0c2599..33e810e 100644 --- a/include/private/dbg_mlc.h +++ b/include/private/dbg_mlc.h @@ -158,7 +158,7 @@ typedef struct { #endif #if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH) -# ifdef SHORT_DBG_HDRS +# if defined(SHORT_DBG_HDRS) && !defined(CPPCHECK) # error Non-ptr stored in object results in GC_HAS_DEBUG_INFO malfunction /* We may mistakenly conclude that p has a debugging wrapper. */ # endif diff --git a/include/private/gc_atomic_ops.h b/include/private/gc_atomic_ops.h index 776d455..ef982d5 100644 --- a/include/private/gc_atomic_ops.h +++ b/include/private/gc_atomic_ops.h @@ -109,7 +109,7 @@ /* only if AO_REQUIRE_CAS is defined (or if the corresponding */ /* AO_HAVE_x macro is defined). x86/x64 targets have AO_nop_full, */ /* AO_load_acquire, AO_store_release, at least. */ -# if !defined(AO_HAVE_load) || !defined(AO_HAVE_store) +# if (!defined(AO_HAVE_load) || !defined(AO_HAVE_store)) && !defined(CPPCHECK) # error AO_load or AO_store is missing; probably old version of atomic_ops # endif diff --git a/include/private/gc_hdrs.h b/include/private/gc_hdrs.h index 94f29e9..a6e7037 100644 --- a/include/private/gc_hdrs.h +++ b/include/private/gc_hdrs.h @@ -15,7 +15,7 @@ #ifndef GC_HEADERS_H #define GC_HEADERS_H -#if CPP_WORDSZ != 32 && CPP_WORDSZ < 36 +#if CPP_WORDSZ != 32 && CPP_WORDSZ < 36 && !defined(CPPCHECK) # error Get a real machine #endif diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 12c4ae4..9274d1b 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -860,8 +860,8 @@ EXTERN_C_BEGIN # define CPP_LOG_HBLKSIZE 13 # elif HBLKSIZE == 16384 # define CPP_LOG_HBLKSIZE 14 -# else -# error fix HBLKSIZE +# elif !defined(CPPCHECK) +# error Bad HBLKSIZE value # endif # undef HBLKSIZE #endif diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 9863a87..9da9c0d 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -1274,8 +1274,8 @@ EXTERN_C_BEGIN # define OS_TYPE "LINUX" # ifdef __ELF__ # define DYNAMIC_LOADING -# else -# error --> Linux SPARC a.out not supported +# elif !defined(CPPCHECK) +# error Linux SPARC a.out not supported # endif extern int _end[]; extern int _etext[]; @@ -1347,7 +1347,7 @@ EXTERN_C_BEGIN # ifdef I386 # define MACH_TYPE "I386" -# if defined(__LP64__) || defined(_WIN64) +# if (defined(__LP64__) || defined(_WIN64)) && !defined(CPPCHECK) # error This should be handled as X86_64 # else # define CPP_WORDSZ 32 @@ -2099,8 +2099,8 @@ EXTERN_C_BEGIN /* Requires 8 byte alignment for malloc */ # define ALIGNMENT 4 # else -# ifndef _LP64 -# error --> unknown ABI +# if !defined(_LP64) && !defined(CPPCHECK) +# error Unknown ABI # endif # define CPP_WORDSZ 64 /* Requires 16 byte alignment for malloc */ @@ -3043,10 +3043,8 @@ EXTERN_C_BEGIN #if defined(CPPCHECK) # undef CPP_WORDSZ # define CPP_WORDSZ (__SIZEOF_POINTER__ * 8) -#endif - -#if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 -# error --> bad word size +#elif CPP_WORDSZ != 32 && CPP_WORDSZ != 64 +# error Bad word size #endif #if !defined(ALIGNMENT) && !defined(CPPCHECK) -- 2.7.4