From e870802a19c103302aaac993c40419ba34d3ff3d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 15 Jun 2012 18:24:18 +0400 Subject: [PATCH] test_cpp: Suppress GCC warnings in WinMain * tests/test_cpp.cc (ATTR_UNUSED): New macro. * tests/test_cpp.cc (WinMain): Tag "instance", "prev" and "cmdShow" arguments with ATTR_UNUSED. * tests/test_cpp.cc (WinMain): Explicitly cast "xio", "f", "d", "a" local variables to void (to suppress "variable set but not used" compiler warning). --- tests/test_cpp.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index f1393729..597d8088 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -70,6 +70,11 @@ extern "C" { __LINE__ ); \ exit( 1 ); } +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# define ATTR_UNUSED __attribute__((__unused__)) +#else +# define ATTR_UNUSED /* empty */ +#endif class A {public: /* An uncollectable class. */ @@ -187,8 +192,8 @@ void* Undisguise( GC_word i ) { return (void*) ~ i;} #ifdef MSWIN32 -int APIENTRY WinMain( - HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow ) +int APIENTRY WinMain( HINSTANCE instance ATTR_UNUSED, + HINSTANCE prev ATTR_UNUSED, LPSTR cmd, int cmdShow ATTR_UNUSED ) { int argc; char* argv[ 3 ]; @@ -212,6 +217,7 @@ int APIENTRY WinMain( int *x = gc_allocator().allocate(1); int *xio; xio = gc_allocator_ignore_off_page().allocate(1); + (void)xio; int **xptr = traceable_allocator().allocate(1); # else int *x = (int *)gc_alloc::allocate(sizeof(int)); @@ -245,7 +251,9 @@ int APIENTRY WinMain( D* d; F* f; d = ::new (USE_GC, D::CleanUp, (void*)(GC_word)i) D( i ); + (void)d; f = new F; + (void)f; if (0 == i % 10) delete c;} /* Allocate a very large number of collectable As and Bs and @@ -254,6 +262,7 @@ int APIENTRY WinMain( for (i = 0; i < 1000000; i++) { A* a; a = new (USE_GC) A( i ); + (void)a; B* b = new B( i ); b = new (USE_GC) B( i ); if (0 == i % 10) { -- 2.50.1