build: disable Pragmas for pre 4.6 gcc

Gcc 4.6 introduced Pragma "GCC diagnostic" (https://gcc.gnu.org/gcc-4.6/changes.html)
Don't use them for older gcc.

[thaller@redhat.com: modified original patch]

https://bugzilla.gnome.org/show_bug.cgi?id=757910
(cherry picked from commit 6263703286)
This commit is contained in:
Glenn Washburn 2015-11-13 16:42:08 +01:00 committed by Thomas Haller
parent 9488e40d34
commit 6a9d8c7fa4
2 changed files with 11 additions and 2 deletions

View file

@ -84,7 +84,7 @@
* It's not that bad however, because gcc and clang often have the
* same name for the same warning. */
#if defined (__GNUC__)
#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define NM_PRAGMA_WARNING_DISABLE(warning) \
_Pragma("GCC diagnostic push"); \
_Pragma(_NM_PRAGMA_WARNING_DO(warning))
@ -96,7 +96,7 @@
#define NM_PRAGMA_WARNING_DISABLE(warning)
#endif
#if defined (__GNUC__)
#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define NM_PRAGMA_WARNING_REENABLE \
_Pragma("GCC diagnostic pop")
#elif defined (__clang__)

View file

@ -46,6 +46,7 @@
#define _alignas_(x) __attribute__((aligned(__alignof(x))))
#define _cleanup_(x) __attribute__((cleanup(x)))
#if (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) || defined (__clang__)
/* Temporarily disable some warnings */
#define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT \
_Pragma("GCC diagnostic push"); \
@ -69,6 +70,14 @@
#define REENABLE_WARNING \
_Pragma("GCC diagnostic pop")
#else
#define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT
#define DISABLE_WARNING_FORMAT_NONLITERAL
#define DISABLE_WARNING_MISSING_PROTOTYPES
#define DISABLE_WARNING_NONNULL
#define DISABLE_WARNING_SHADOW
#define REENABLE_WARNING
#endif
/* automake test harness */
#define EXIT_TEST_SKIP 77