[v16,60/60] lib: add compile warning about use of VLAs

Message ID 1736821958-3295-61-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Changes Requested
Delegated to: David Marchand
Headers
Series remove use of VLAs for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS

Commit Message

Andre Muezerie Jan. 14, 2025, 2:32 a.m. UTC
MSVC does not support VLAs, so we want to prevent VLAs from being
introduced under this path.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/lib/meson.build b/lib/meson.build
index ce92cb5537..43a92be5fa 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -111,9 +111,13 @@  default_cflags = machine_args
 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
 default_cflags += ['-DALLOW_INTERNAL_API']
 
-if cc.has_argument('-Wno-format-truncation')
-    default_cflags += '-Wno-format-truncation'
-endif
+extra_flags = ['-Wno-format-truncation', '-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        default_cflags += arg
+    endif
+endforeach
 
 foreach l:libraries
     build = true