testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / data-model-20.c
blob59f62853ad6a8e86aa6391fcf0d08d1de4642114
1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
3 #include <stdlib.h>
5 struct foo { int dummy; };
7 struct foo **
8 test (int n) {
9 struct foo **arr;
10 int i;
12 if ((arr = (struct foo **)malloc(n * sizeof(struct foo *))) == NULL)
13 return NULL;
15 for (i = 0; i < n; i++) {
16 if ((arr[i] = (struct foo *)malloc(sizeof(struct foo))) == NULL) {
17 for (; i >= 0; i++) { /* { dg-warning "infinite loop" } */
18 /* This loop is in the wrong direction, so not technically an
19 infinite loop ("i" will eventually wrap around), but the
20 analyzer's condition handling treats the overflow as such.
21 In any case, the code is suspect and warrants a warning. */
22 free(arr[i]); /* { dg-bogus "double-'free'" } */
24 free(arr); /* { dg-warning "leak" } */
25 return NULL;
28 return arr;