diff gcc/testsuite/gcc.dg/Walloca-larger-than.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children 1830386684a0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/Walloca-larger-than.c	Thu Oct 25 07:37:49 2018 +0900
@@ -0,0 +1,26 @@
+/* PR middle-end/82063 - issues with arguments enabled by -Wall
+   { dg-do compile }
+   { dg-options "-O2 -Walloca-larger-than=0 -Wvla-larger-than=0 -ftrack-macro-expansion=0" } */
+
+extern void* alloca (__SIZE_TYPE__);
+
+void sink (void*);
+
+#define T(x) sink (x)
+
+void test_alloca (void)
+{
+  /* Verify that alloca(0) is diagnosed even if the limit is zero.  */
+  T (alloca (0));   /* { dg-warning "argument to .alloca. is zero" } */
+  T (alloca (1));   /* { dg-warning "argument to .alloca. is too large" } */
+}
+
+void test_vla (unsigned n)
+{
+  /* VLAs smaller than 32 bytes are optimized into ordinary arrays.  */
+  if (n < 1 || 99 < n)
+    n = 1;
+
+  char a[n];        /* { dg-warning "argument to variable-length array " } */
+  T (a);
+}