diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-03-20 05:19:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 05:19:45 (GMT) |
commit | b5397f0abeff67e314c68c7cb807a432b474dbfa (patch) | |
tree | 258856d51cf353e8910a92f92d8a57a9fe67db24 /src | |
parent | 6d881fe7755298d1c92c86d153b4f8097b86c483 (diff) | |
download | hdf5-b5397f0abeff67e314c68c7cb807a432b474dbfa.zip hdf5-b5397f0abeff67e314c68c7cb807a432b474dbfa.tar.gz hdf5-b5397f0abeff67e314c68c7cb807a432b474dbfa.tar.bz2 |
Bring warning macro changes from develop (#2594)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5private.h | 103 | ||||
-rw-r--r-- | src/H5public.h | 49 |
2 files changed, 100 insertions, 52 deletions
diff --git a/src/H5private.h b/src/H5private.h index 47132a0..319f43c 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -251,52 +251,69 @@ * gcc warnings (it has to use the public API and can't include this * file). Be sure to update that file if the #ifdefs change here. */ +/* clang-format off */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) -#define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) -#define H5_ATTR_UNUSED __attribute__((unused)) -#ifdef H5_HAVE_PARALLEL -#define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) -#define H5_ATTR_PARALLEL_USED /*void*/ -#else -#define H5_ATTR_PARALLEL_UNUSED /*void*/ -#define H5_ATTR_PARALLEL_USED __attribute__((unused)) -#endif -#ifdef H5_NO_DEPRECATED_SYMBOLS -#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED -#else /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5_ATTR_DEPRECATED_USED /*void*/ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ -#ifdef H5_DEBUG_API -#define H5_ATTR_DEBUG_API_USED /*void*/ -#else /* H5_DEBUG_API */ -#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED -#endif /* H5_DEBUG_API */ -#ifndef NDEBUG -#define H5_ATTR_NDEBUG_UNUSED /*void*/ -#else /* NDEBUG */ -#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED -#endif /* NDEBUG */ -#define H5_ATTR_NORETURN __attribute__((noreturn)) -#define H5_ATTR_CONST __attribute__((const)) -#define H5_ATTR_PURE __attribute__((pure)) -#if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) -#define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); -#else -#define H5_ATTR_FALLTHROUGH /* FALLTHROUGH */ -#endif +# define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) +# define H5_ATTR_UNUSED __attribute__((unused)) + +# ifdef H5_HAVE_PARALLEL +# define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) +# define H5_ATTR_PARALLEL_USED /*void*/ +# else +# define H5_ATTR_PARALLEL_UNUSED /*void*/ +# define H5_ATTR_PARALLEL_USED __attribute__((unused)) +# endif + +# ifdef H5_NO_DEPRECATED_SYMBOLS +# define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED +# else +# define H5_ATTR_DEPRECATED_USED /*void*/ +# endif + +# ifdef H5_DEBUG_API +# define H5_ATTR_DEBUG_API_USED /*void*/ +# else +# define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED +# endif /* H5_DEBUG_API */ + +# ifndef NDEBUG +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# else +# define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED +# endif + +# define H5_ATTR_NORETURN __attribute__((noreturn)) +# define H5_ATTR_CONST __attribute__((const)) +# define H5_ATTR_PURE __attribute__((pure)) + +# if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) +# define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); +# else +# define H5_ATTR_FALLTHROUGH /* FALLTHROUGH */ +# endif + +# if defined(__GNUC__) && !defined(__INTEL_COMPILER) +# define H5_ATTR_MALLOC __attribute__((malloc)) +# else +# define H5_ATTR_MALLOC /*void*/ +# endif + #else -#define H5_ATTR_FORMAT(X, Y, Z) /*void*/ -#define H5_ATTR_UNUSED /*void*/ -#define H5_ATTR_NDEBUG_UNUSED /*void*/ -#define H5_ATTR_DEBUG_API_USED /*void*/ -#define H5_ATTR_DEPRECATED_USED /*void*/ -#define H5_ATTR_PARALLEL_UNUSED /*void*/ -#define H5_ATTR_PARALLEL_USED /*void*/ -#define H5_ATTR_NORETURN /*void*/ -#define H5_ATTR_CONST /*void*/ -#define H5_ATTR_PURE /*void*/ -#define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_FORMAT(X, Y, Z) /*void*/ +# define H5_ATTR_UNUSED /*void*/ +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# define H5_ATTR_DEBUG_API_USED /*void*/ +# define H5_ATTR_DEPRECATED_USED /*void*/ +# define H5_ATTR_PARALLEL_UNUSED /*void*/ +# define H5_ATTR_PARALLEL_USED /*void*/ +# define H5_ATTR_NORETURN /*void*/ +# define H5_ATTR_CONST /*void*/ +# define H5_ATTR_PURE /*void*/ +# define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_MALLOC /*void*/ +# define H5_ATTR_NO_OPTIMIZE /*void*/ #endif +/* clang-format on */ /* * Networking headers used by the mirror VFD and related tests and utilities. diff --git a/src/H5public.h b/src/H5public.h index a932e64..0fa92fa 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -77,24 +77,55 @@ extern "C" { #endif -/* Macros for enabling/disabling particular GCC warnings */ -/* (see the following web-sites for more info: +/* Macros for enabling/disabling particular GCC / clang warnings + * + * These are duplicated in H5FDmulti.c (we don't want to put them in the + * public header and the multi VFD can't use private headers). If you make + * changes here, be sure to update those as well. + * + * (see the following web-sites for more info: * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas */ -/* These pragmas are only implemented usefully in gcc 4.6+ */ -#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 -#define H5_GCC_DIAG_JOINSTR(x, y) x y -#define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma(#x) -#define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x) +#define H5_DIAG_JOINSTR(x, y) x y +#define H5_DIAG_DO_PRAGMA(x) _Pragma(#x) +#define H5_DIAG_PRAGMA(x) H5_DIAG_DO_PRAGMA(GCC diagnostic x) + +#define H5_DIAG_OFF(x) H5_DIAG_PRAGMA(push) H5_DIAG_PRAGMA(ignored H5_DIAG_JOINSTR("-W", x)) +#define H5_DIAG_ON(x) H5_DIAG_PRAGMA(pop) -#define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR("-W", x)) -#define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop) +/* Macros for enabling/disabling particular GCC-only warnings. + * These pragmas are only implemented usefully in gcc 4.6+ + */ +#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) +#define H5_GCC_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_GCC_DIAG_ON(x) H5_DIAG_ON(x) #else #define H5_GCC_DIAG_OFF(x) #define H5_GCC_DIAG_ON(x) #endif +/* Macros for enabling/disabling particular clang-only warnings. + */ +#if defined(__clang__) +#define H5_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_CLANG_DIAG_ON(x) H5_DIAG_ON(x) +#else +#define H5_CLANG_DIAG_OFF(x) +#define H5_CLANG_DIAG_ON(x) +#endif + +/* Macros for enabling/disabling particular GCC / clang warnings. + * These macros should be used for warnings supported by both gcc and clang. + */ +#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__) +#define H5_GCC_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_GCC_CLANG_DIAG_ON(x) H5_DIAG_ON(x) +#else +#define H5_GCC_CLANG_DIAG_OFF(x) +#define H5_GCC_CLANG_DIAG_ON(x) +#endif + /* Version numbers */ /** * For major interface/format changes |