changeset 6453:3624b11235ba

8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas Summary: Added conditions around macro definitions for pragmas. Reviewed-by: kvn
author simonis
date Wed, 14 May 2014 12:09:13 -0400
parents 99dc0ff1d4c7
children c98ef93bfe9a
files src/share/vm/utilities/globalDefinitions_gcc.hpp
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/utilities/globalDefinitions_gcc.hpp	Tue Mar 11 15:06:34 2014 +0400
+++ b/src/share/vm/utilities/globalDefinitions_gcc.hpp	Wed May 14 12:09:13 2014 -0400
@@ -283,13 +283,25 @@
 #define VALUE_OBJ_CLASS_SPEC
 
 #ifndef ATTRIBUTE_PRINTF
+// Diagnostic pragmas like the ones defined below in PRAGMA_FORMAT_NONLITERAL_IGNORED
+// were only introduced in GCC 4.2. Because we have no other possibility to ignore
+// these warnings for older versions of GCC, we simply don't decorate our printf-style
+// functions with __attribute__(format) in that case.
+#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4)
 #define ATTRIBUTE_PRINTF(fmt,vargs)  __attribute__((format(printf, fmt, vargs)))
+#else
+#define ATTRIBUTE_PRINTF(fmt,vargs)
+#endif
 #endif
 
-#define PRAGMA_FORMAT_NONLITERAL_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") _Pragma("GCC diagnostic ignored \"-Wformat-security\"")
+#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\"")
 
-#if defined(__clang_major__) && (__clang_major__ >= 4 || (__clang_major__ >= 3 && __clang_minor__ >= 1)) || (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
+#if defined(__clang_major__) && \
+      (__clang_major__ >= 4 || \
+      (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \
+    ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
 // Tested to work with clang version 3.1 and better.
 #define PRAGMA_DIAG_PUSH             _Pragma("GCC diagnostic push")
 #define PRAGMA_DIAG_POP              _Pragma("GCC diagnostic pop")