Path: blob/master/src/hotspot/share/utilities/compilerWarnings_gcc.hpp
40949 views
/*1* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP25#define SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP2627// Macros related to control of compiler warnings.2829#ifndef ATTRIBUTE_PRINTF30#define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs)))31#endif32#ifndef ATTRIBUTE_SCANF33#define ATTRIBUTE_SCANF(fmt,vargs) __attribute__((format(scanf, fmt, vargs)))34#endif3536#define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x)37#define PRAGMA_DISABLE_GCC_WARNING(option_string) \38PRAGMA_DISABLE_GCC_WARNING_AUX(GCC diagnostic ignored option_string)3940#define PRAGMA_FORMAT_NONLITERAL_IGNORED \41PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \42PRAGMA_DISABLE_GCC_WARNING("-Wformat-security")4344#define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat")4546// Disable -Wstringop-truncation which is introduced in GCC 8.47// https://gcc.gnu.org/gcc-8/changes.html48#if !defined(__clang_major__) && (__GNUC__ >= 8)49#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")50#endif5152#if defined(__clang_major__) && \53(__clang_major__ >= 4 || \54(__clang_major__ >= 3 && __clang_minor__ >= 1)) || \55((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)56// Tested to work with clang version 3.1 and better.57#define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push")58#define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop")5960#endif // clang/gcc version check6162#endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP636465