]> granicus.if.org Git - gc/commitdiff
test_cpp: Suppress GCC warnings in WinMain
authorIvan Maidanski <ivmai@mail.ru>
Fri, 15 Jun 2012 14:24:18 +0000 (18:24 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 15 Jun 2012 14:24:18 +0000 (18:24 +0400)
* 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

index f13937293170feaaea4fbabb6af5c9c1af739462..597d8088c82ab70e91c5ba0447b719c87ef33e1b 100644 (file)
@@ -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<int>().allocate(1);
       int *xio;
       xio = gc_allocator_ignore_off_page<int>().allocate(1);
+      (void)xio;
       int **xptr = traceable_allocator<int *>().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) {