[Piglit] [PATCH 7/7] cmake: Warn when variable length arrays are used.

Emil Velikov emil.l.velikov at gmail.com
Fri Nov 7 09:55:25 PST 2014


On 07/11/14 14:21, jfonseca at vmware.com wrote:
> From: José Fonseca <jfonseca at vmware.com>
> 
> As these are not supported on MSVC, not even MSVC 2013 since it only has
> library support for C99, it doesn't actually support C99 syntax.
> 
I do recall that msvc2013 just errors out in such cases, yet I've not
seen any issues with piglit though. Either way this is a worthy addition
imho.

Additionally, msvc2013 supports declarations after statements but _only_
for base types. Anything (class/struct/typedef) that the user creates
themselves tends to explode quite badly.

So C99 is almost of there, after some 14+years :)

-Emil

> Suggested by Jan Vesely.
> ---
>  CMakeLists.txt | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 50e8cc8..d1792d0 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -222,7 +222,11 @@ if (NOT MSVC)
>  	CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" 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)
> +	ENDIF ()
> +	CHECK_C_COMPILER_FLAG("-Wvla" C_COMPILER_FLAG_WDECL_AFTER_STMT)
> +	IF (C_COMPILER_FLAG_WDECL_AFTER_STMT)
> +		SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla")
> +	ENDIF ()
>  
>  	CHECK_CXX_COMPILER_FLAG("-Wno-narrowing" CXX_COMPILER_FLAG_WNO_NARROWING)
>  	IF (CXX_COMPILER_FLAG_WNO_NARROWING)
> 



More information about the Piglit mailing list