[Piglit] [PATCH 1/2] cmake: Warn when placing declarations after statements.
Ian Romanick
idr at freedesktop.org
Thu Jan 19 08:56:13 PST 2012
On 01/17/2012 11:29 AM, jfonseca at vmware.com wrote:
> From: José Fonseca<jfonseca at vmware.com>
>
> Unfortunately this will enable the warning even on OS specific directories
> will never be built with MSVC, but it looks like the use of this C99 is
> actually very scarce, even on those OS specific directories.
There's probably a way in cmake to change the flags per directory, but I
doubt it's worth the effort. For the series,
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> CMakeLists.txt | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 179340e..d4b5b2a 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -56,6 +56,14 @@ if (NOT MSVC)
> IF (CXX_COMPILER_FLAG_WALL)
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
> ENDIF (CXX_COMPILER_FLAG_WALL)
> +
> + # Unfortunately MSVC does not support C99. Among all features enabled
> + # by C99, declarations after statements is the most frequently used.
> + # For portability sake, we request gcc to warn when this is used.
> + CHECK_C_COMPILER_FLAG("-Wall" C_COMPILER_FLAG_WDECL_AFTER_STMT)
> + IF (C_COMPILER_FLAG_WDECL_AFTER_STMT)
> + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
> + ENDIF (C_COMPILER_FLAG_WDECL_AFTER_STMT)
> else ()
> # -Wall or (/Wall) is actually supported by MSVC and would be detected
> # by CHECK_C_COMPILER_FLAG above, but is very pedantic, causing
More information about the Piglit
mailing list