[PATCH] Conditionalize use of -Wno-suggest-attribute=format pragma

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 532a777..b412a42 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 9855c49..4d473af 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")
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]