[v12,18/21] build: enable vla warnings on Windows built code

Message ID 1732225298-10322-19-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series remove use of VLAs for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Nov. 21, 2024, 9:41 p.m. UTC
From: Tyler Retzlaff <roretzla@linux.microsoft.com>

MSVC does not support optional C11 VLAs. When building for Windows
enable -Wvla so that mingw and clang also fail if a VLA is used.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

fengchengwen Nov. 22, 2024, 12:50 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2024/11/22 5:41, Andre Muezerie wrote:
> From: Tyler Retzlaff <roretzla@linux.microsoft.com>
> 
> MSVC does not support optional C11 VLAs. When building for Windows
> enable -Wvla so that mingw and clang also fail if a VLA is used.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/meson.build | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/config/meson.build b/config/meson.build
> index 6aaad6d8a4..ebca19b4e5 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -342,6 +342,10 @@ if cc.get_id() == 'intel'
>          warning_flags += '-diag-disable=@0@'.format(i)
>      endforeach
>  endif
> +# no VLAs in code built on Windows
> +if is_windows
> +    warning_flags += '-Wvla'
> +endif
>  foreach arg: warning_flags
>      if cc.has_argument(arg)
>          add_project_arguments(arg, language: 'c')
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 6aaad6d8a4..ebca19b4e5 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -342,6 +342,10 @@  if cc.get_id() == 'intel'
         warning_flags += '-diag-disable=@0@'.format(i)
     endforeach
 endif
+# no VLAs in code built on Windows
+if is_windows
+    warning_flags += '-Wvla'
+endif
 foreach arg: warning_flags
     if cc.has_argument(arg)
         add_project_arguments(arg, language: 'c')