tests: Fix for non-GCC

Remove uses of using empty arrays in initialization and structs, and build
tests that rely on GCCisms on GCC only.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
This commit is contained in:
Chun-wei Fan 2013-11-06 16:45:12 +08:00
parent a7707ec60b
commit c58a7b8c74
2 changed files with 38 additions and 32 deletions

View File

@ -21,7 +21,9 @@
/* We test for errors in optimize-only definitions in gmem.h */ /* We test for errors in optimize-only definitions in gmem.h */
#ifdef __GNUC__
#pragma GCC optimize (1) #pragma GCC optimize (1)
#endif
#include "glib.h" #include "glib.h"
#include <stdlib.h> #include <stdlib.h>
@ -169,6 +171,7 @@ mem_overflow (void)
CHECK_SUBPROCESS_PASS (realloc_0); CHECK_SUBPROCESS_PASS (realloc_0);
} }
#ifdef __GNUC__
typedef struct typedef struct
{ {
} Empty; } Empty;
@ -193,6 +196,7 @@ empty_alloc (void)
g_test_trap_subprocess ("/mem/empty-alloc/subprocess", 0, 0); g_test_trap_subprocess ("/mem/empty-alloc/subprocess", 0, 0);
g_test_trap_assert_passed (); g_test_trap_assert_passed ();
} }
#endif
int int
main (int argc, main (int argc,
@ -224,8 +228,10 @@ main (int argc,
g_test_add_func ("/mem/overflow/subprocess/malloc_0", mem_overflow_malloc_0); g_test_add_func ("/mem/overflow/subprocess/malloc_0", mem_overflow_malloc_0);
g_test_add_func ("/mem/overflow/subprocess/realloc_0", mem_overflow_realloc_0); g_test_add_func ("/mem/overflow/subprocess/realloc_0", mem_overflow_realloc_0);
#ifdef __GNUC__
g_test_add_func ("/mem/empty-alloc", empty_alloc); g_test_add_func ("/mem/empty-alloc", empty_alloc);
g_test_add_func ("/mem/empty-alloc/subprocess", empty_alloc_subprocess); g_test_add_func ("/mem/empty-alloc/subprocess", empty_alloc_subprocess);
#endif
return g_test_run(); return g_test_run();
} }

View File

@ -535,56 +535,56 @@ test_interface_default_init (TestInterfaceInterface *iface)
static gint valid_impl_types[48][4] = { static gint valid_impl_types[48][4] = {
/* a b c GObject */ /* a b c GObject */
/* 'a-' */ { }, /* 'a-' */ { 0, },
/* 'a-r' */ { 'v', 'v', '<', '<' }, /* 'a-r' */ { 'v', 'v', '<', '<' },
/* 'a-w' */ { 'v', '>', '>', 'v' }, /* 'a-w' */ { 'v', '>', '>', 'v' },
/* 'a-rw' */ { 'v', '=', '=', '=' }, /* 'a-rw' */ { 'v', '=', '=', '=' },
/* 'a-c */ { }, /* 'a-c */ { 0, },
/* 'a-rc' */ { }, /* 'a-rc' */ { 0, },
/* 'a-wc' */ { 'v', '>', '>', 'v' }, /* 'a-wc' */ { 'v', '>', '>', 'v' },
/* 'a-rwc' */ { 'v', '=', '=', '=' }, /* 'a-rwc' */ { 'v', '=', '=', '=' },
/* 'a-C */ { }, /* 'a-C */ { 0, },
/* 'a-rC' */ { }, /* 'a-rC' */ { 0, },
/* 'a-wC' */ { 'v', '>', '>', 'v' }, /* 'a-wC' */ { 'v', '>', '>', 'v' },
/* 'a-rwC' */ { 'v', '=', '=', '=' }, /* 'a-rwC' */ { 'v', '=', '=', '=' },
/* 'a-cC */ { }, /* 'a-cC */ { 0, },
/* 'a-rcC' */ { }, /* 'a-rcC' */ { 0, },
/* 'a-wcC' */ { }, /* 'a-wcC' */ { 0, },
/* 'a-rwcC' */ { }, /* 'a-rwcC' */ { 0, },
/* 'b-' */ { }, /* 'b-' */ { 0, },
/* 'b-r' */ { '<', 'v', '<', '<' }, /* 'b-r' */ { '<', 'v', '<', '<' },
/* 'b-w' */ { 'v', 'v', '>', 'v' }, /* 'b-w' */ { 'v', 'v', '>', 'v' },
/* 'b-rw' */ { '=', 'v', '=', '=' }, /* 'b-rw' */ { '=', 'v', '=', '=' },
/* 'b-c */ { }, /* 'b-c */ { 0, },
/* 'b-rc' */ { }, /* 'b-rc' */ { 0, },
/* 'b-wc' */ { 'v', 'v', '>', 'v' }, /* 'b-wc' */ { 'v', 'v', '>', 'v' },
/* 'b-rwc' */ { '=', 'v', '=', '=' }, /* 'b-rwc' */ { '=', 'v', '=', '=' },
/* 'b-C */ { }, /* 'b-C */ { 0, },
/* 'b-rC' */ { }, /* 'b-rC' */ { 0, },
/* 'b-wC' */ { 'v', 'v', '>', 'v' }, /* 'b-wC' */ { 'v', 'v', '>', 'v' },
/* 'b-rwC' */ { '=', 'v', '=', '=' }, /* 'b-rwC' */ { '=', 'v', '=', '=' },
/* 'b-cC */ { }, /* 'b-cC */ { 0, },
/* 'b-rcC' */ { }, /* 'b-rcC' */ { 0, },
/* 'b-wcC' */ { }, /* 'b-wcC' */ { 0, },
/* 'b-rwcC' */ { }, /* 'b-rwcC' */ { 0, },
/* 'c-' */ { }, /* 'c-' */ { 0, },
/* 'c-r' */ { '<', '<', 'v', '<' }, /* 'c-r' */ { '<', '<', 'v', '<' },
/* 'c-w' */ { '>', '>', 'v', 'v' }, /* 'c-w' */ { '>', '>', 'v', 'v' },
/* 'c-rw' */ { '=', '=', 'v', '=' }, /* 'c-rw' */ { '=', '=', 'v', '=' },
/* 'c-c */ { }, /* 'c-c */ { 0, },
/* 'c-rc' */ { }, /* 'c-rc' */ { 0, },
/* 'c-wc' */ { '>', '>', 'v', 'v' }, /* 'c-wc' */ { '>', '>', 'v', 'v' },
/* 'c-rwc' */ { '=', '=', 'v', '=' }, /* 'c-rwc' */ { '=', '=', 'v', '=' },
/* 'c-C */ { }, /* 'c-C */ { 0, },
/* 'c-rC' */ { }, /* 'c-rC' */ { 0, },
/* 'c-wC' */ { '>', '>', 'v', 'v' }, /* 'c-wC' */ { '>', '>', 'v', 'v' },
/* 'c-rwC' */ { '=', '=', 'v', '=' }, /* 'c-rwC' */ { '=', '=', 'v', '=' },
/* 'c-cC */ { }, /* 'c-cC */ { 0, },
/* 'c-rcC' */ { }, /* 'c-rcC' */ { 0, },
/* 'c-wcC' */ { }, /* 'c-wcC' */ { 0, },
/* 'c-rwcC' */ { } /* 'c-rwcC' */ { 0, }
}; };
/* We also try to change the flags. We must ensure that all /* We also try to change the flags. We must ensure that all
@ -624,16 +624,16 @@ static gint valid_impl_types[48][4] = {
*/ */
static gint valid_impl_flags[16][16] = { static gint valid_impl_flags[16][16] = {
/* '' r w rw c rc wc rwc C rC wC rwC cC rcC wcC rwcC */ /* '' r w rw c rc wc rwc C rC wC rwC cC rcC wcC rwcC */
/* '*-' */ { }, /* '*-' */ { 0, },
/* '*-r' */ { 'i', 'v', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'i', 'i' }, /* '*-r' */ { 'i', 'v', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'i', 'i' },
/* '*-w' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'r', 'r', 'i', 'i', 'i', 'i' }, /* '*-w' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'r', 'r', 'i', 'i', 'i', 'i' },
/* '*-rw' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'r', 'i', 'i', 'i', 'i' }, /* '*-rw' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'r', 'i', 'i', 'i', 'i' },
/* '*-c */ { }, /* '*-c */ { 0, },
/* '*-rc' */ { }, /* '*-rc' */ { 0, },
/* '*-wc' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'r', 'r', 'i', 'i', 'i', 'i' }, /* '*-wc' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'r', 'r', 'i', 'i', 'i', 'i' },
/* '*-rwc' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'r', 'i', 'i', 'i', 'i' }, /* '*-rwc' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'r', 'i', 'i', 'i', 'i' },
/* '*-C */ { }, /* '*-C */ { 0, },
/* '*-rC' */ { }, /* '*-rC' */ { 0, },
/* '*-wC' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'i', 'i' }, /* '*-wC' */ { 'i', 'f', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'v', 'v', 'i', 'i', 'i', 'i' },
/* '*-rwC' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'i', 'i' }, /* '*-rwC' */ { 'i', 'f', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'f', 'v', 'i', 'i', 'i', 'i' },
}; };