From 9cb9f34edd62f4e73a9329336b81da821104825d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 22 Sep 2015 15:06:18 -0700 Subject: [PATCH] fix some core test warnings --- tests/core/test_alloca_stack.in | 2 +- tests/core/test_atoX.in | 22 +++++++++++----------- tests/core/test_i64_7z.in | 2 +- tests/core/test_i64_varargs.in | 2 +- tests/core/test_llvm_fabs.c | 2 +- tests/core/test_strcmp_uni.in | 2 +- tests/ctype/src.c | 2 +- tests/emscripten_get_now.cpp | 2 +- tests/freetype/main_2.c | 4 ++-- tests/fs/test_nodefs_rw.c | 1 + tests/test_core.py | 16 ++++++++++------ tests/webidl/test.h | 2 +- 12 files changed, 32 insertions(+), 27 deletions(-) diff --git a/tests/core/test_alloca_stack.in b/tests/core/test_alloca_stack.in index ba3afcc77..983ea3dbc 100644 --- a/tests/core/test_alloca_stack.in +++ b/tests/core/test_alloca_stack.in @@ -2,7 +2,7 @@ #include #include -func(int i) { +int func(int i) { char *pc = (char *)alloca(100); *pc = i; (*pc)++; diff --git a/tests/core/test_atoX.in b/tests/core/test_atoX.in index 327871b8b..0f5a19fd9 100644 --- a/tests/core/test_atoX.in +++ b/tests/core/test_atoX.in @@ -13,17 +13,17 @@ int main() { printf("%d*", atoi(" 3 7")); printf("%d*", atoi("9 d")); printf("%d\n", atoi(" 8 e")); - printf("%d*", atol("")); - printf("%d*", atol("a")); - printf("%d*", atol(" b")); - printf("%d*", atol(" c ")); - printf("%d*", atol("6")); - printf("%d*", atol(" 5")); - printf("%d*", atol("4 ")); - printf("%d*", atol("3 6")); - printf("%d*", atol(" 3 7")); - printf("%d*", atol("9 d")); - printf("%d\n", atol(" 8 e")); + printf("%d*", (int)atol("")); + printf("%d*", (int)atol("a")); + printf("%d*", (int)atol(" b")); + printf("%d*", (int)atol(" c ")); + printf("%d*", (int)atol("6")); + printf("%d*", (int)atol(" 5")); + printf("%d*", (int)atol("4 ")); + printf("%d*", (int)atol("3 6")); + printf("%d*", (int)atol(" 3 7")); + printf("%d*", (int)atol("9 d")); + printf("%d\n", (int)atol(" 8 e")); printf("%lld*", atoll("6294967296")); printf("%lld*", atoll("")); printf("%lld*", atoll("a")); diff --git a/tests/core/test_i64_7z.in b/tests/core/test_i64_7z.in index c15bfd782..4cdfabcc1 100644 --- a/tests/core/test_i64_7z.in +++ b/tests/core/test_i64_7z.in @@ -4,7 +4,7 @@ uint64_t a, b; int main(int argc, char *argv[]) { a = argc; b = argv[1][0]; - printf("%d,%d\n", a, b); + printf("%d,%d\n", (int)a, (int)b); if (a > a + b || a > a + b + 1) { printf("one %lld, %lld", a, b); return 0; diff --git a/tests/core/test_i64_varargs.in b/tests/core/test_i64_varargs.in index a0cbec64a..b8d9628a8 100644 --- a/tests/core/test_i64_varargs.in +++ b/tests/core/test_i64_varargs.in @@ -16,7 +16,7 @@ int64_t ccv_cache_generate_signature(char *msg, int len, int64_t sig_start, } int main(int argc, char **argv) { - argv[0] = "..."; + argv[0] = (char*)"..."; for (int i = 0; i < argc; i++) { int64_t x; if (i % 123123 == 0) diff --git a/tests/core/test_llvm_fabs.c b/tests/core/test_llvm_fabs.c index 9961eda01..6094013d8 100644 --- a/tests/core/test_llvm_fabs.c +++ b/tests/core/test_llvm_fabs.c @@ -22,7 +22,7 @@ int main() { printf("%f\n", __builtin_fabsf(negative10())); printf("%f\n", __builtin_fabsf(positive42())); - printf("%f\n", __builtin_fabsf(negative_dbl_max())); + printf("%f\n", __builtin_fabsf((float)negative_dbl_max())); printf("%f\n", __builtin_fabs(negative10())); printf("%f\n", __builtin_fabs(positive42())); diff --git a/tests/core/test_strcmp_uni.in b/tests/core/test_strcmp_uni.in index 82819dde3..fd16490d7 100644 --- a/tests/core/test_strcmp_uni.in +++ b/tests/core/test_strcmp_uni.in @@ -3,7 +3,7 @@ int main() { #define TEST(func) \ { \ - char *word = "WORD"; \ + char *word = (char*)"WORD"; \ char wordEntry[2] = {-61, -126}; /* "Â"; */ \ int cmp = func(word, wordEntry, 2); \ printf("Compare value " #func " is %d\n", cmp); \ diff --git a/tests/ctype/src.c b/tests/ctype/src.c index 3fe99b256..a8be35b97 100644 --- a/tests/ctype/src.c +++ b/tests/ctype/src.c @@ -37,7 +37,7 @@ int main() { isprint, isgraph }; - char* funcNames[] = { + const char* funcNames[] = { "isascii", "islower", "isupper", diff --git a/tests/emscripten_get_now.cpp b/tests/emscripten_get_now.cpp index 5ededb230..1259b604b 100644 --- a/tests/emscripten_get_now.cpp +++ b/tests/emscripten_get_now.cpp @@ -3,7 +3,7 @@ #ifndef REPORT_RESULT // To be able to run this test outside the browser harness in node.js/spidermonkey: -#define REPORT_RESULT int dummy +#define REPORT_RESULT() #endif int result = 0; diff --git a/tests/freetype/main_2.c b/tests/freetype/main_2.c index 85e5609d9..e9dd7f013 100644 --- a/tests/freetype/main_2.c +++ b/tests/freetype/main_2.c @@ -89,7 +89,7 @@ main( int argc, } // Only test the character 'w' - text = "w"; + text = (char*)"w"; filename = argv[1]; /* first argument */ WIDTH = atoi(argv[3]); @@ -132,4 +132,4 @@ main( int argc, return 0; } -/* EOF */ \ No newline at end of file +/* EOF */ diff --git a/tests/fs/test_nodefs_rw.c b/tests/fs/test_nodefs_rw.c index 140da3326..ce3041965 100644 --- a/tests/fs/test_nodefs_rw.c +++ b/tests/fs/test_nodefs_rw.c @@ -1,5 +1,6 @@ #include #include +#include #include int main() { diff --git a/tests/test_core.py b/tests/test_core.py index 21cda682c..5f37e7ef7 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -53,7 +53,7 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co long long x = 0x0000def123450789ULL; // any bigger than this, and we long long y = 0x00020ef123456089ULL; // start to run into the double precision limit! - printf("*%lld,%lld,%lld,%lld,%lld*\\n", x, y, x | y, x & y, x ^ y, x >> 2, y << 2); + printf("*%lld,%lld,%lld,%lld,%lld*\\n", x, y, x | y, x & y, x ^ y); printf("*"); long long z = 13; @@ -1548,7 +1548,7 @@ int main () { try { Polymorphic * pb = 0; - typeid(*pb); // throws a bad_typeid exception + const std::type_info& ti = typeid(*pb); // throws a bad_typeid exception } catch (std::exception& e) { @@ -2173,7 +2173,7 @@ int main() { int main(int argc, char **argv) { char *buf1 = (char*)malloc(100); - char *data1 = "hello"; + char *data1 = (char*)"hello"; memcpy(buf1, data1, strlen(data1)+1); float *buf2 = (float*)malloc(100); @@ -2185,7 +2185,7 @@ int main() { int totalMemory = emscripten_run_script_int("TOTAL_MEMORY"); char *buf3 = (char*)malloc(totalMemory+1); buf3[argc] = (int)buf2; - if (argc % 7 == 6) printf("%d\n", memcpy(buf3, buf1, argc)); + if (argc % 7 == 6) printf("%d\n", (int)memcpy(buf3, buf1, argc)); char *buf4 = (char*)malloc(100); float *buf5 = (float*)malloc(100); //printf("totalMemory: %d bufs: %d,%d,%d,%d,%d\n", totalMemory, buf1, buf2, buf3, buf4, buf5); @@ -5534,7 +5534,7 @@ struct one_const addr_of_my_consts = { }; int main(void) { - printf("%li\n", !!addr_of_my_consts.a); + printf("%li\n", (long)!!addr_of_my_consts.a); return 0; } ''', '1') @@ -5607,8 +5607,10 @@ int main(void) { def test_dlmalloc_partial(self): # present part of the symbols of dlmalloc, not all src = open(path_from_root('tests', 'new.cpp')).read().replace('{{{ NEW }}}', 'new int').replace('{{{ DELETE }}}', 'delete') + ''' +#include + void * -operator new(size_t size) +operator new(size_t size) throw(std::bad_alloc) { printf("new %d!\\n", size); return malloc(size); @@ -7746,6 +7748,8 @@ def make_run(fullname, name=-1, compiler=-1, embetter=0, quantum_size=0, Settings.load(self.emcc_args) Building.LLVM_OPTS = 0 + Building.COMPILER_TEST_OPTS += ['-Wno-dynamic-class-memaccess', '-Wno-format', '-Wno-format-extra-args', '-Wno-format-security', '-Wno-pointer-bool-conversion', '-Wno-unused-volatile-lvalue', '-Wno-c++11-compat-deprecated-writable-strings', '-Wno-invalid-pp-token'] + for arg in self.emcc_args: if arg.startswith('-O'): Building.COMPILER_TEST_OPTS.append(arg) # so bitcode is optimized too, this is for cpp to ll diff --git a/tests/webidl/test.h b/tests/webidl/test.h index 94ba44097..b7954149d 100644 --- a/tests/webidl/test.h +++ b/tests/webidl/test.h @@ -119,7 +119,7 @@ class TypeTestClass { unsigned short int ReturnUnsignedShortMethod() { return (2<<15)-1; } void AcceptUnsignedShortMethod(unsigned short x) { printf("unsigned short int: %u\n", x); } - unsigned long ReturnUnsignedLongMethod() { return (2<<31)-1; } + unsigned long ReturnUnsignedLongMethod() { return 0xffffffff; } void AcceptUnsignedLongMethod(unsigned long x) { printf("unsigned long int: %u\n", x); } };