middle-end: Fix stalled swapped condition code value [PR115836]
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / realloc-5.c
blobd469ae9306b5a7d2254ced90ca2c33230ab3ee12
1 /* { dg-additional-options "-fno-analyzer-suppress-followups" } */
3 #include "../../gcc.dg/analyzer/analyzer-decls.h"
5 typedef __SIZE_TYPE__ size_t;
8 extern void *malloc (size_t __size)
9 __attribute__ ((__nothrow__ , __leaf__))
10 __attribute__ ((__malloc__))
11 __attribute__ ((__alloc_size__ (1)));
12 extern void *realloc (void *__ptr, size_t __size)
13 __attribute__ ((__nothrow__ , __leaf__))
14 __attribute__ ((__warn_unused_result__))
15 __attribute__ ((__alloc_size__ (2)));
16 extern void free (void *__ptr)
17 __attribute__ ((__nothrow__ , __leaf__));
18 extern void *memset (void *__ptr, int __value, size_t __size);
20 /* realloc where the region shrinks on success_with_move. */
22 void test_1 ()
24 char *p = (char *) malloc (16);
25 if (!p)
26 return;
27 memset (p, 1, 16);
29 char *q = (char *) realloc (p, 8);
30 if (!q)
32 free (p);
33 return;
35 else if (p != q)
37 __analyzer_dump_capacity (q); /* { dg-warning "capacity: '\\(\[^\n\r\]*\\)8'" } */
38 __analyzer_eval (q[8] == 1); /* { dg-line eval } */
40 /* { dg-warning "UNKNOWN" "warning" { target *-*-* } eval } */
41 /* { dg-warning "heap-based buffer over-read" "warning" { target *-*-* } eval } */
44 free (q);