src/hotspot/share/utilities/compilerWarnings_gcc.hpp
author mr
Tue, 29 Oct 2019 13:52:04 -0700
changeset 58850 f4290bf1cc21
parent 58682 9f5b92d5a1b2
permissions -rw-r--r--
8233137: runtime/ErrorHandling/VeryEarlyAssertTest.java fails after 8232080 Reviewed-by: stuefe, iignatyev, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     4
 *
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     8
 *
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    14
 *
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    18
 *
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    21
 * questions.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    22
 *
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    23
 */
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    24
53645
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    25
#ifndef SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    26
#define SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    27
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    28
// Macros related to control of compiler warnings.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    29
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    30
// Diagnostic pragmas like the ones defined below in PRAGMA_FORMAT_NONLITERAL_IGNORED
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    31
// were only introduced in GCC 4.2. Because we have no other possibility to ignore
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    32
// these warnings for older versions of GCC, we simply don't decorate our printf-style
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    33
// functions with __attribute__(format) in that case.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    34
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4)
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    35
#ifndef ATTRIBUTE_PRINTF
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    36
#define ATTRIBUTE_PRINTF(fmt,vargs)  __attribute__((format(printf, fmt, vargs)))
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    37
#endif
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    38
#ifndef ATTRIBUTE_SCANF
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    39
#define ATTRIBUTE_SCANF(fmt,vargs)  __attribute__((format(scanf, fmt, vargs)))
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    40
#endif
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    41
#endif // gcc version check
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    42
53645
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    43
#define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x)
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    44
#define PRAGMA_DISABLE_GCC_WARNING(option_string) \
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    45
  PRAGMA_DISABLE_GCC_WARNING_AUX(GCC diagnostic ignored option_string)
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    46
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    47
#define PRAGMA_FORMAT_NONLITERAL_IGNORED                \
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    48
  PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral")     \
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    49
  PRAGMA_DISABLE_GCC_WARNING("-Wformat-security")
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    50
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    51
#define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat")
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    52
58682
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    53
// Disable -Wstringop-truncation which is introduced in GCC 8.
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    54
// https://gcc.gnu.org/gcc-8/changes.html
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    55
#if !defined(__clang_major__) && (__GNUC__ >= 8)
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    56
#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    57
#endif
9f5b92d5a1b2 8232084: HotSpot build failed with GCC 9.2.1
ysuenaga
parents: 53645
diff changeset
    58
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    59
#if defined(__clang_major__) && \
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    60
      (__clang_major__ >= 4 || \
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    61
      (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    62
    ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    63
// Tested to work with clang version 3.1 and better.
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    64
#define PRAGMA_DIAG_PUSH             _Pragma("GCC diagnostic push")
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    65
#define PRAGMA_DIAG_POP              _Pragma("GCC diagnostic pop")
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    66
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    67
#endif // clang/gcc version check
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
diff changeset
    68
53645
2c6c0fabe6a2 8218164: Improve local control of compiler warnings
kbarrett
parents: 53244
diff changeset
    69
#endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP