From f63047a3d1d0ed27c1efdde9ca81b0e62f9f6e69 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 15 Feb 2013 17:08:45 +0000 Subject: [PATCH] Fix warnings-as-errors for clang It seems like some versions of clang have a problem with using pragmas to stop particular warnings being converted to errors with -Werror. These compilers require that the warning be ignored completely in order to suppress it. Make the necessary changes to afsd and bozo, and update README.WARNINGS to note the problem. Change-Id: I66038130695d2ad27c289f29bcd8f6f2eddf1ded Reviewed-on: http://gerrit.openafs.org/9135 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear --- README.WARNINGS | 11 +++++++++++ src/afsd/afsd_kernel.c | 6 +++++- src/bozo/bosserver.c | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.WARNINGS b/README.WARNINGS index 7a6abd63e0..fa5fb8fb4f 100644 --- a/README.WARNINGS +++ b/README.WARNINGS @@ -27,6 +27,17 @@ with non-gcc compilers, and can be disabled if desired. For example: # pragma GCC diagnostic warning "-Wold-style-definition" #endif +It would appear that when built with -Werror, the llvm clang compiler will +still upgrade warnings that are suppresed in this way to errors. In this case, +the fix is to mark that warning as ignored, but only for clang. For example: + #ifdef IGNORE_SOME_GCC_WARNINGS + # ifdef __clang__ + # pragma GCC diagnostic ignored "-Wdeprecated-declarations" + # else + # pragma GCC diagnostic warning "-Wdeprecated-declarations" + # endif + #endif + If a pragma isn't available for your particular warning, you will need to disable all warnings for the file in question. You can do this by supplying the autoconf macro @CFLAGS_NOERROR@ in the build options for the file. For diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c index 2f5f780629..7800fcbad9 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -13,7 +13,11 @@ #include #ifdef IGNORE_SOME_GCC_WARNINGS -# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif #endif #define VFS 1 diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index 0885f23669..4c68b33f6f 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -15,7 +15,11 @@ #include #ifdef IGNORE_SOME_GCC_WARNINGS -# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# ifdef __clang__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif #endif #ifdef HAVE_SYS_RESOURCE_H