brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1012 B · ae6b7e9 Raw
60 lines · c
1// RUN: %clang_analyze_cc1 -triple x86_64-unknown-freebsd %s2 3#include "Inputs/system-header-simulator.h"4 5#define M_ZERO 0x01006#define NULL ((void *)0)7 8void *malloc(size_t, void *, int);9void free(void *);10 11struct test {12};13 14void foo(struct test *);15 16void test_zeroed(void) {17  struct test **list, *t;18  int i;19 20  list = malloc(sizeof(*list) * 10, NULL, M_ZERO);21  if (list == NULL)22    return;23 24  for (i = 0; i < 10; i++) {25    t = list[i];26    foo(t);27  }28  free(list); // no-warning29}30 31void test_nonzero(void) {32  struct test **list, *t;33  int i;34 35  list = malloc(sizeof(*list) * 10, NULL, 0);36  if (list == NULL)37    return;38 39  for (i = 0; i < 10; i++) {40    t = list[i]; // expected-warning{{undefined}}41    foo(t);42  }43  free(list);44}45 46void test_indeterminate(int flags) {47  struct test **list, *t;48  int i;49 50  list = malloc(sizeof(*list) * 10, NULL, flags);51  if (list == NULL)52    return;53 54  for (i = 0; i < 10; i++) {55    t = list[i]; // expected-warning{{undefined}}56    foo(t);57  }58  free(list);59}60