From 31d037e41bcd81ee2be95088ab99a7b969b48d29 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 6 Oct 2016 01:12:55 +0300 Subject: [PATCH] Workaround '#error' cppcheck error messages * extra/msvc_dbg.c (GetStackFramesFromContext): Skip #error pragma if CPPCHECK. * include/private/gcconfig.h [sun && mc68000]: Likewise. * include/private/gcconfig.h [hp9000s300 || ibm032 || _AUX_SOURCE || __pj__]: Likewise. * include/private/gcconfig.h [!mach_type_known]: Likewise. * include/private/gcconfig.h [HEXAGON && LINUX && !__ELF__]: Likewise. * include/private/gcconfig.h [!ALIGNMENT || !STACKBOTTOM]: Likewise. * os_dep.c [USE_MUNMAP && !USE_MMAP]: Likewise. * os_dep.c [MPROTECT_VDB && DARWIN && !ARM32 && !AARCH64 && !POWERPC && !I386]: Likewise. --- extra/msvc_dbg.c | 4 ++-- include/private/gcconfig.h | 19 ++++++++++--------- os_dep.c | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/extra/msvc_dbg.c b/extra/msvc_dbg.c index abf4671..e7d7291 100644 --- a/extra/msvc_dbg.c +++ b/extra/msvc_dbg.c @@ -158,8 +158,8 @@ size_t GetStackFramesFromContext(HANDLE hProcess, HANDLE hThread, #elif defined(_M_ALPHA64) machineType = IMAGE_FILE_MACHINE_ALPHA64; stackFrame.AddrPC.Offset = context->Fir; -#else -#error Unknown CPU +#elif !defined(CPPCHECK) +# error Unknown CPU #endif for (frameIndex = 0; frameIndex < maxFrames; ) { BOOL bRet = StackWalk(machineType, hProcess, hThread, &stackFrame, diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index d4a9199..98df369 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -118,10 +118,10 @@ # define mach_type_known # endif # endif -# if defined(sun) && defined(mc68000) +# if defined(sun) && defined(mc68000) && !defined(CPPCHECK) # error SUNOS4 no longer supported # endif -# if defined(hp9000s300) +# if defined(hp9000s300) && !defined(CPPCHECK) # error M68K based HP machines no longer supported. # endif # if defined(OPENBSD) && defined(m68k) @@ -223,7 +223,7 @@ # define OS2 # define mach_type_known # endif -# if defined(ibm032) +# if defined(ibm032) && !defined(CPPCHECK) # error IBM PC/RT no longer supported. # endif # if defined(sun) && (defined(sparc) || defined(__sparc)) @@ -259,7 +259,7 @@ # endif # define mach_type_known # endif -# if defined(_AUX_SOURCE) +# if defined(_AUX_SOURCE) && !defined(CPPCHECK) # error A/UX no longer supported # endif # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \ @@ -525,7 +525,7 @@ # define UTS4 # define mach_type_known # endif -# if defined(__pj__) +# if defined(__pj__) && !defined(CPPCHECK) # error PicoJava no longer supported /* The implementation had problems, and I haven't heard of users */ /* in ages. If you want it resurrected, let me know. */ @@ -600,7 +600,7 @@ /* Macros such as LINUX, FREEBSD, etc. distinguish them. */ /* SYSV on an M68K actually means A/UX. */ /* The distinction in these cases is usually the stack starting address */ -# ifndef mach_type_known +# if !defined(mach_type_known) && !defined(CPPCHECK) # error "The collector has not been ported to this machine/OS combination." # endif /* Mapping is: M68K ==> Motorola 680X0 */ @@ -2574,7 +2574,7 @@ # endif extern int _end[]; # define DATAEND ((ptr_t)(_end)) -# else +# elif !defined(CPPCHECK) # error --> bad Hexagon Linux configuration # endif # else @@ -2782,7 +2782,7 @@ # error --> bad word size #endif -#ifndef ALIGNMENT +#if !defined(ALIGNMENT) && !defined(CPPCHECK) # error --> undefined ALIGNMENT #endif @@ -2796,7 +2796,8 @@ # define PCR_VDB #endif -#if !defined(STACKBOTTOM) && (defined(ECOS) || defined(NOSYS)) +#if !defined(STACKBOTTOM) && (defined(ECOS) || defined(NOSYS)) \ + && !defined(CPPCHECK) # error --> undefined STACKBOTTOM #endif diff --git a/os_dep.c b/os_dep.c index 92ff6d2..e5cbfb2 100644 --- a/os_dep.c +++ b/os_dep.c @@ -69,7 +69,7 @@ #endif #if defined(MMAP_SUPPORTED) || defined(ADD_HEAP_GUARD_PAGES) -# if defined(USE_MUNMAP) && !defined(USE_MMAP) +# if defined(USE_MUNMAP) && !defined(USE_MMAP) && !defined(CPPCHECK) # error "invalid config - USE_MUNMAP requires USE_MMAP" # endif # include @@ -4199,7 +4199,7 @@ STATIC kern_return_t GC_forward_exception(mach_port_t thread, mach_port_t task, # define DARWIN_EXC_STATE_T x86_exception_state64_t # endif # define DARWIN_EXC_STATE_DAR THREAD_FLD_NAME(faultvaddr) -#else +#elif !defined(CPPCHECK) # error FIXME for non-arm/ppc/x86 darwin #endif -- 2.7.4