testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / sprintf-concat.c
blobad744588bc0c0e229cf31d65e3d1f2dc3f96b9fd
1 typedef __SIZE_TYPE__ size_t;
2 #include "../../gcc.dg/analyzer/analyzer-decls.h"
4 extern size_t
5 strlen(const char* __s) __attribute__((__nothrow__, __leaf__))
6 __attribute__((__pure__)) __attribute__((__nonnull__(1)));
8 extern void*
9 malloc(size_t __size) __attribute__((__nothrow__, __leaf__))
10 __attribute__((__malloc__)) __attribute__((__alloc_size__(1)));
12 extern int
13 sprintf(char* __restrict __s, const char* __restrict, ...)
14 __attribute__((__nothrow__));
16 char *
17 test_1 (const char *a, const char *b)
19 size_t sz = strlen (a) + strlen (b) + 2;
20 char *p = (char *) malloc (sz);
21 if (!p)
22 return NULL;
23 sprintf (p, "%s/%s", a, b);
24 return p;
27 void
28 test_2 (const char *a, const char *b)
30 size_t sz = strlen (a) + strlen (b) + 2;
31 char *p = (char *) malloc (sz); /* { dg-message "allocated here" } */
32 if (!p)
33 return;
34 sprintf (p, "%s/%s", a, b); /* { dg-warning "leak of 'p' " } */