From 442bcbfaf2ab0db8bc2890d44f8829224038ecdd Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 20 Apr 2017 11:17:20 +0300 Subject: [PATCH] Eliminate 'unused formal parameter' compiler warnings in C++ code (MS VC) * include/gc_allocator.h (GC_ATTR_UNUSED): Remove. * tests/test_cpp.cc (ATTR_UNUSED): Likewise. * include/gc_allocator.h (gc_allocator::deallocate, gc_allocator_ignore_off_page::deallocate, traceable_allocator::deallocate): Comment out unused argument name instead of using GC_ATTR_UNUSED. * include/gc_cpp.h [_MSC_VER && !GC_DEBUG] (operator new): Comment out unused argument names. * tests/test_cpp.cc [(MSWIN32 && !__MINGW32__ || MSWINCE) && !NO_WINMAIN_ENTRY] (WinMain): Comment out unused argument names instead of using ATTR_UNUSED. --- include/gc_allocator.h | 12 +++--------- include/gc_cpp.h | 20 ++++++++++++-------- tests/test_cpp.cc | 11 ++--------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/include/gc_allocator.h b/include/gc_allocator.h index 3ea80a07..9d70ed5a 100644 --- a/include/gc_allocator.h +++ b/include/gc_allocator.h @@ -44,12 +44,6 @@ #include "gc.h" #include // for placement new -#if defined(__GNUC__) -# define GC_ATTR_UNUSED __attribute__((__unused__)) -#else -# define GC_ATTR_UNUSED -#endif - #ifndef GC_ATTR_EXPLICIT # if (__cplusplus >= 201103L) || defined(CPPCHECK) # define GC_ATTR_EXPLICIT explicit @@ -142,7 +136,7 @@ public: } // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) + void deallocate(pointer __p, size_type /* GC_n */) { GC_FREE(__p); } size_type max_size() const throw() @@ -219,7 +213,7 @@ public: } // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) + void deallocate(pointer __p, size_type /* GC_n */) { GC_FREE(__p); } size_type max_size() const throw() @@ -295,7 +289,7 @@ public: } // __p is not permitted to be a null pointer. - void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) + void deallocate(pointer __p, size_type /* GC_n */) { GC_FREE(__p); } size_type max_size() const throw() diff --git a/include/gc_cpp.h b/include/gc_cpp.h index 920b8368..d41a0f52 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -306,15 +306,19 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp, } // This new operator is used by VC++ in case of Debug builds: - inline void* operator new(size_t size, int /* nBlockUse */, - const char* szFileName, int nLine) - { -# ifndef GC_DEBUG - return GC_malloc_uncollectable(size); -# else +# ifdef GC_DEBUG + inline void* operator new(size_t size, int /* nBlockUse */, + const char* szFileName, int nLine) + { return GC_debug_malloc_uncollectable(size, szFileName, nLine); -# endif - } + } +# else + inline void* operator new(size_t size, int /* nBlockUse */, + const char* /* szFileName */, int /* nLine */) + { + return GC_malloc_uncollectable(size); + } +# endif /* !GC_DEBUG */ # if _MSC_VER > 1020 // This new operator is used by VC++ 7+ in Debug builds: diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index 902a8247..bb18ed54 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -70,12 +70,6 @@ extern "C" { __LINE__ ); \ exit( 1 ); } -#if GC_GNUC_PREREQ(3, 4) -# define ATTR_UNUSED __attribute__((__unused__)) -#else -# define ATTR_UNUSED /* empty */ -#endif - #ifndef GC_ATTR_EXPLICIT # if (__cplusplus >= 201103L) || defined(CPPCHECK) # define GC_ATTR_EXPLICIT explicit @@ -207,9 +201,8 @@ void* Undisguise( GC_word i ) { #if ((defined(MSWIN32) && !defined(__MINGW32__)) || defined(MSWINCE)) \ && !defined(NO_WINMAIN_ENTRY) - int APIENTRY WinMain( HINSTANCE instance ATTR_UNUSED, - HINSTANCE prev ATTR_UNUSED, LPSTR cmd, - int cmdShow ATTR_UNUSED ) + int APIENTRY WinMain( HINSTANCE /* instance */, HINSTANCE /* prev */, + LPSTR cmd, int /* cmdShow */) { int argc = 0; char* argv[ 3 ]; -- 2.40.0