From 87fa184910e3157115921f5ceb0803b057183b3f Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" <berrange@redhat.com> Date: Fri, 16 Jan 2015 14:45:08 +0000 Subject: [PATCH] Conditionalize use of -Wno-suggest-attribute=format pragma Many GCC versions don't understand -Wno-suggest-attribute=format so the pragma must only be used when supported --- m4/virt-compile-warnings.m4 | 6 ++++++ src/internal.h | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 532a7777e8..8aebdb0541 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -215,6 +215,12 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ ;; esac + case $WARN_CFLAGS in + *-Wsuggest-attribute=format*) + AC_DEFINE([HAVE_SUGGEST_ATTRIBUTE_FORMAT], [1], [Whether -Wsuggest-attribute=format works]) + ;; + esac + # Silence certain warnings in gnulib, and use improved glibc headers AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.]) diff --git a/src/internal.h b/src/internal.h index 9855c49912..4d473afdf9 100644 --- a/src/internal.h +++ b/src/internal.h @@ -234,9 +234,15 @@ # define VIR_WARNINGS_NO_CAST_ALIGN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wcast-align\"") -# define VIR_WARNINGS_NO_PRINTF \ + +# if HAVE_SUGGEST_ATTRIBUTE_FORMAT +# define VIR_WARNINGS_NO_PRINTF \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=format\"") +# else +# define VIR_WARNINGS_NO_PRINTF \ + _Pragma ("GCC diagnostic push") +# endif # define VIR_WARNINGS_RESET \ _Pragma ("GCC diagnostic pop")