[PATCH] D46012: Avoid a warning on pointer casting, NFC

Gabor Buella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 07:13:42 PDT 2018


GBuella created this revision.
GBuella added a reviewer: philip.pfaffe.
Herald added a subscriber: llvm-commits.

The warning was:

  unittests/Passes/PluginsTest.cpp:30:23: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     void *Ptr = (void *)anchor;
                            ^


Repository:
  rL LLVM

https://reviews.llvm.org/D46012

Files:
  unittests/Passes/PluginsTest.cpp


Index: unittests/Passes/PluginsTest.cpp
===================================================================
--- unittests/Passes/PluginsTest.cpp
+++ unittests/Passes/PluginsTest.cpp
@@ -19,15 +19,17 @@
 
 #include "TestPlugin.h"
 
+#include <cstdint>
+
 using namespace llvm;
 
 void anchor() {}
 
 static std::string LibPath(const std::string Name = "TestPlugin") {
   const std::vector<testing::internal::string> &Argvs =
       testing::internal::GetArgvs();
   const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "PluginsTests";
-  void *Ptr = (void *)anchor;
+  void *Ptr = (void *)(intptr_t)anchor;
   std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
   llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
   sys::path::append(Buf, (Name + ".so").c_str());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46012.143740.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180424/ca7f1316/attachment.bin>


More information about the llvm-commits mailing list