# HG changeset patch
# User andrew
# Date 1527661161 -3600
#      Wed May 30 07:19:21 2018 +0100
# Node ID 8cde8f606e3f4f7c8809d9c1ebc71e45615f7402
# Parent  ef176cb429c49d1c330d9575938f66b04e3fb730
PR3597: Potential bogus -Wformat-overflow warning with -Wformat enabled

diff --git openjdk.orig/hotspot/src/share/vm/adlc/adlc.hpp openjdk/hotspot/src/share/vm/adlc/adlc.hpp
--- openjdk.orig/hotspot/src/share/vm/adlc/adlc.hpp
+++ openjdk/hotspot/src/share/vm/adlc/adlc.hpp
@@ -85,6 +85,19 @@
 #undef max
 #define max(a, b)   (((a)>(b)) ? (a) : (b))
 
+#if !defined(__clang_major__) && (__GNUC__ >= 7)
+#define PRAGMA_DIAG_PUSH             _Pragma("GCC diagnostic push")
+#define PRAGMA_DIAG_POP              _Pragma("GCC diagnostic pop")
+#define PRAGMA_FORMAT_OVERFLOW_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat-overflow\"")
+#define PRAGMA_FORMAT_OVERFLOW_IGNORED_EXTERNAL PRAGMA_FORMAT_OVERFLOW_IGNORED
+#define PRAGMA_FORMAT_OVERFLOW_IGNORED_INTERNAL PRAGMA_FORMAT_OVERFLOW_IGNORED
+#else
+#define PRAGMA_DIAG_PUSH
+#define PRAGMA_DIAG_POP
+#define PRAGMA_FORMAT_OVERFLOW_IGNORED_EXTERNAL
+#define PRAGMA_FORMAT_OVERFLOW_IGNORED_INTERNAL
+#endif
+
 // ADLC components
 #include "arena.hpp"
 #include "opto/adlcVMDeps.hpp"
diff --git openjdk.orig/hotspot/src/share/vm/adlc/output_c.cpp openjdk/hotspot/src/share/vm/adlc/output_c.cpp
--- openjdk.orig/hotspot/src/share/vm/adlc/output_c.cpp
+++ openjdk/hotspot/src/share/vm/adlc/output_c.cpp
@@ -560,6 +560,8 @@
   return (ndx);
 }
 
+PRAGMA_DIAG_PUSH
+PRAGMA_FORMAT_OVERFLOW_IGNORED_EXTERNAL
 void ArchDesc::build_pipe_classes(FILE *fp_cpp) {
   const char *classname;
   const char *resourcename;
@@ -1016,6 +1018,7 @@
   fprintf(fp_cpp, "}\n");
   fprintf(fp_cpp, "#endif\n");
 }
+PRAGMA_DIAG_POP
 
 // ---------------------------------------------------------------------------
 //------------------------------Utilities to build Instruction Classes--------
