comparison 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
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* PR middle-end/82063 - issues with arguments enabled by -Wall
2 { dg-do compile }
3 { dg-options "-O2 -Walloca-larger-than=0 -Wvla-larger-than=0 -ftrack-macro-expansion=0" } */
4
5 extern void* alloca (__SIZE_TYPE__);
6
7 void sink (void*);
8
9 #define T(x) sink (x)
10
11 void test_alloca (void)
12 {
13 /* Verify that alloca(0) is diagnosed even if the limit is zero. */
14 T (alloca (0)); /* { dg-warning "argument to .alloca. is zero" } */
15 T (alloca (1)); /* { dg-warning "argument to .alloca. is too large" } */
16 }
17
18 void test_vla (unsigned n)
19 {
20 /* VLAs smaller than 32 bytes are optimized into ordinary arrays. */
21 if (n < 1 || 99 < n)
22 n = 1;
23
24 char a[n]; /* { dg-warning "argument to variable-length array " } */
25 T (a);
26 }