[PATCH] D50056: [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.

Andrei Elovikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 1 06:42:20 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC338551: [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang… (authored by a.elovikov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50056?vs=158483&id=158527#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50056

Files:
  tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===================================================================
--- tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -149,7 +149,23 @@
   EE->runStaticConstructorsDestructors(false);
 
   typedef void (*func)(int*, int*, int*, int);
-  func f = reinterpret_cast<func>(EE->getPointerToFunction(EntryFunc)); 
+#if defined(__GNUC__) && !defined(__clang) &&                                  \
+    ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+// Silence
+//
+//   warning: ISO C++ forbids casting between pointer-to-function and
+//   pointer-to-object [-Wpedantic]
+//
+// Since C++11 this casting is conditionally supported and GCC versions
+// starting from 4.9.0 don't warn about the cast.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+  func f = reinterpret_cast<func>(EE->getPointerToFunction(EntryFunc));
+#if defined(__GNUC__) && !defined(__clang) &&                                  \
+    ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+#pragma GCC diagnostic pop
+#endif
 
   // Define some dummy arrays to use an input for now
   int a[] = {1};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50056.158527.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180801/89f60afb/attachment-0001.bin>


More information about the cfe-commits mailing list