[llvm] r286396 - [tools] Unbreak the GCC build (workaround a GCC bug).

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 13:30:33 PST 2016


Author: davide
Date: Wed Nov  9 15:30:33 2016
New Revision: 286396

URL: http://llvm.org/viewvc/llvm-project?rev=286396&view=rev
Log:
[tools] Unbreak the GCC build (workaround a GCC bug).

../tools/llvm-extract/llvm-extract.cpp: In function ‘int main(int, char**)’:
warning: ISO C++ forbids zero-size array ‘argv’ [-Wpedantic]

GCC reference bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61259

Modified:
    llvm/trunk/tools/lli/lli.cpp
    llvm/trunk/tools/llvm-extract/llvm-extract.cpp

Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=286396&r1=286395&r2=286396&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Nov  9 15:30:33 2016
@@ -418,7 +418,8 @@ int main(int argc, char **argv, char * c
 
   // If not jitting lazily, load the whole bitcode file eagerly too.
   if (NoLazyCompilation) {
-    ExitOnError ExitOnErr(std::string(argv[0]) +
+    // Use *argv instead of argv[0] to work around a wrong GCC warning.
+    ExitOnError ExitOnErr(std::string(*argv) +
                           ": bitcode didn't read correctly: ");
     ExitOnErr(Mod->materializeAll());
   }

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=286396&r1=286395&r2=286396&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Wed Nov  9 15:30:33 2016
@@ -223,7 +223,8 @@ int main(int argc, char **argv) {
     }
   }
 
-  ExitOnError ExitOnErr(std::string(argv[0]) + ": error reading input: ");
+  // Use *argv instead of argv[0] to work around a wrong GCC warning.
+  ExitOnError ExitOnErr(std::string(*argv) + ": error reading input: ");
 
   auto Materialize = [&](GlobalValue &GV) { ExitOnErr(GV.materialize()); };
 




More information about the llvm-commits mailing list