diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-06 19:06:16 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-06 19:06:16 +0000 |
commit | 0f2ba783d9ffacfc9ccbe94beb76d48bf958a066 (patch) | |
tree | 54418d358a2009b21ba7fb6feda6ade01e6322f6 /unittests/ExecutionEngine/JIT | |
parent | 60b35bd8ecb2c3358b80d8441873cfffa0d27851 (diff) | |
download | external_llvm-0f2ba783d9ffacfc9ccbe94beb76d48bf958a066.zip external_llvm-0f2ba783d9ffacfc9ccbe94beb76d48bf958a066.tar.gz external_llvm-0f2ba783d9ffacfc9ccbe94beb76d48bf958a066.tar.bz2 |
Fix illegal cross-type aliasing. Found by baldrick on a newer gcc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ExecutionEngine/JIT')
-rw-r--r-- | unittests/ExecutionEngine/JIT/JITTest.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp index ee27dee..a4812bc 100644 --- a/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -99,9 +99,8 @@ TEST(JIT, GlobalInFunction) { // Get the pointer to the native code to force it to JIT the function and // allocate space for the global. - void (*F1Ptr)(); - // Hack to avoid ISO C++ warning about casting function pointers. - *(void**)(void*)&F1Ptr = JIT->getPointerToFunction(F1); + void (*F1Ptr)() = + reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F1)); // Since F1 was codegen'd, a pointer to G should be available. int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G); @@ -115,9 +114,8 @@ TEST(JIT, GlobalInFunction) { // Make a second function identical to the first, referring to the same // global. Function *F2 = makeReturnGlobal("F2", G, M); - // Hack to avoid ISO C++ warning about casting function pointers. - void (*F2Ptr)(); - *(void**)(void*)&F2Ptr = JIT->getPointerToFunction(F2); + void (*F2Ptr)() = + reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F2)); // F2() should increment G. F2Ptr(); |