comparison src/share/vm/utilities/globalDefinitions_gcc.hpp @ 17937:78bbf4d43a14

8037816: Fix for 8036122 breaks build with Xcode5/clang 8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas 8043164: Format warning in traceStream.hpp Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings Reviewed-by: kvn, coleenp, iveresov, twisti
author drchase
date Thu, 22 May 2014 15:52:41 -0400
parents fa6d364024c2
children b6a8cc1e0d92
comparison
equal deleted inserted replaced
17935:7384f6a12fc1 17937:78bbf4d43a14
1 /* 1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
280 // Portability macros 280 // Portability macros
281 #define PRAGMA_INTERFACE #pragma interface 281 #define PRAGMA_INTERFACE #pragma interface
282 #define PRAGMA_IMPLEMENTATION #pragma implementation 282 #define PRAGMA_IMPLEMENTATION #pragma implementation
283 #define VALUE_OBJ_CLASS_SPEC 283 #define VALUE_OBJ_CLASS_SPEC
284 284
285 #ifndef ATTRIBUTE_PRINTF
286 // Diagnostic pragmas like the ones defined below in PRAGMA_FORMAT_NONLITERAL_IGNORED
287 // were only introduced in GCC 4.2. Because we have no other possibility to ignore
288 // these warnings for older versions of GCC, we simply don't decorate our printf-style
289 // functions with __attribute__(format) in that case.
290 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4)
291 #define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs)))
292 #else
293 #define ATTRIBUTE_PRINTF(fmt,vargs)
294 #endif
295 #endif
296
297 #define PRAGMA_FORMAT_NONLITERAL_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
298 _Pragma("GCC diagnostic ignored \"-Wformat-security\"")
299 #define PRAGMA_FORMAT_IGNORED _Pragma("GCC diagnostic ignored \"-Wformat\"")
300
301 #if defined(__clang_major__) && \
302 (__clang_major__ >= 4 || \
303 (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \
304 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
305 // Tested to work with clang version 3.1 and better.
306 #define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push")
307 #define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop")
308 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
309 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL PRAGMA_FORMAT_NONLITERAL_IGNORED
310
311 // Hack to deal with gcc yammering about non-security format stuff
312 #else
313 // Old versions of gcc don't do push/pop, also do not cope with this pragma within a function
314 // One method does so much varied printing that it is decorated with both internal and external
315 // versions of the macro-pragma to obtain better checking with newer compilers.
316 #define PRAGMA_DIAG_PUSH
317 #define PRAGMA_DIAG_POP
318 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL PRAGMA_FORMAT_NONLITERAL_IGNORED
319 #define PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
320 #endif
321
322 #ifndef __clang_major__
323 #define PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC _Pragma("GCC diagnostic ignored \"-Wformat\"") _Pragma("GCC diagnostic error \"-Wformat-nonliteral\"") _Pragma("GCC diagnostic error \"-Wformat-security\"")
324 #endif
325
285 #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) 326 #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95)
286 #define TEMPLATE_TABLE_BUG 327 #define TEMPLATE_TABLE_BUG
287 #endif 328 #endif
288 #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 96) 329 #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)
289 #define CONST_SDM_BUG 330 #define CONST_SDM_BUG