Hi,

I've been trying to build latest jdk with gcc 4.4.7 and I hit compile error due to pragma used in function:

/mnt/ramdisk/openjdk/src/hotspot/os/linux/os_linux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions


I'm sending little patch that fixes the issue by wrapping whole function. I've also created a macro for ignoring deprecated declaration inside compilerWarnings.hpp to line up with others.

Can someone please review? If it's ok, I would also need a sponsor.


diff -r 422615764e12 src/hotspot/os/linux/os_linux.inline.hpp
--- a/src/hotspot/os/linux/os_linux.inline.hpp  Thu Mar 15 14:54:10 2018 -0700
+++ b/src/hotspot/os/linux/os_linux.inline.hpp  Fri Mar 16 10:50:24 2018 +0100
@@ -96,13 +96,12 @@
   return ::ftruncate64(fd, length);
 }

-inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
-{
 // readdir_r has been deprecated since glibc 2.24.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19056 for more details.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
+PRAGMA_DIAG_PUSH
+PRAGMA_DEPRECATED_IGNORED
+inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
+{
   dirent* p;
   int status;
   assert(dirp != NULL, "just checking");
@@ -114,11 +113,11 @@
   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
     errno = status;
     return NULL;
-  } else
+  } else {
     return p;
-
-#pragma GCC diagnostic pop
+  }
 }
+PRAGMA_DIAG_POP

 inline int os::closedir(DIR *dirp) {
   assert(dirp != NULL, "argument is NULL");
diff -r 422615764e12 src/hotspot/share/utilities/compilerWarnings.hpp
--- a/src/hotspot/share/utilities/compilerWarnings.hpp Thu Mar 15 14:54:10 2018 -0700 +++ b/src/hotspot/share/utilities/compilerWarnings.hpp Fri Mar 16 10:50:24 2018 +0100
@@ -48,6 +48,7 @@
#define PRAGMA_FORMAT_NONLITERAL_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \ _Pragma("GCC diagnostic ignored \"-Wformat-security\"")
 #define PRAGMA_FORMAT_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat\"")
+#define PRAGMA_DEPRECATED_IGNORED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")

 #if defined(__clang_major__) && \
       (__clang_major__ >= 4 || \


Thanks!

--
Michal Vala
OpenJDK QE
Red Hat Czech

Reply via email to