[PATCH:macros] XORG_STRICT_OPTION: add -Werror=attributes to STRICT_CFLAGS for gcc

Alan Coopersmith alan.coopersmith at oracle.com
Mon May 2 19:13:40 PDT 2011


Flags unknown attributes as errors, if -Werror=attributes is supported.
(The -Werror=* option was first spotted in gcc 4.2.0 manuals.)

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 xorg-macros.m4.in |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index ccbe931..f89efb6 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1356,6 +1356,15 @@ AC_ARG_ENABLE(strict-compilation,
 			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
 if test "x$GCC" = xyes ; then
     STRICT_CFLAGS="-pedantic -Werror"
+    # Add -Werror=attributes if supported (gcc 4.2 & later)
+    AC_MSG_CHECKING([if $CC supports -Werror=attributes])
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $STRICT_CFLAGS -Werror=attributes"
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([return 0;])],
+		      [STRICT_CFLAGS="$STRICT_CFLAGS -Werror=attributes"
+		       AC_MSG_RESULT([yes])],
+		      [AC_MSG_RESULT([no])])
+    CFLAGS="$save_CFLAGS"
 elif test "x$SUNCC" = "xyes"; then
     STRICT_CFLAGS="-errwarn"
 elif test "x$INTELCC" = "xyes"; then
-- 
1.7.3.2



More information about the xorg-devel mailing list