PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / Walloc-size-larger-than-16.c
blob837b69a36d8aeefa1d625cd0b529bdce344e2376
1 /* PR middle-end/82063 - issues with arguments enabled by -Wall
2 { dg-do compile }
3 { dg-options "-O -Walloc-size-larger-than=1zb -ftrack-macro-expansion=0" } */
5 typedef __SIZE_TYPE__ size_t;
7 void sink (void*);
9 #define T(x) sink (x)
11 /* Verify that an invalid -Walloc-size-larger-than argument is diagnosed
12 and rejected without changing the default setting of PTRDIFF_MAX. */
14 void f (void)
16 size_t n = 0;
17 T (__builtin_malloc (n));
19 n = __PTRDIFF_MAX__;
20 T (__builtin_malloc (n));
22 n += 1;
23 T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */
25 n = __SIZE_MAX__ - 1;
26 T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */
28 n = __SIZE_MAX__;
29 T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */
32 /* { dg-warning "invalid argument .1zb. to .-Walloc-size-larger-than=." "" { target *-*-* } 0 } */