(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
pr93695-1.c
       1  /* { dg-additional-options "-Wno-analyzer-too-complex" } */
       2  /* TODO: remove the need for this option (PR analyzer/93695).  */
       3  
       4  #define NELEMS 10
       5  #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
       6  
       7  void
       8  test_1 (void)
       9  {
      10    int *p[NELEMS];
      11    int i;
      12  
      13    for (i = 0; i < ARRAY_SIZE (p); ++i)
      14      p[i] = __builtin_malloc (sizeof (i));
      15  
      16    for (i = 0; i < ARRAY_SIZE (p); ++i)
      17      __builtin_free (p [i]);
      18  }
      19  
      20  void
      21  test_2 (int n)
      22  {
      23    int **p;
      24    int i;
      25  
      26    p = (int **)__builtin_malloc (sizeof (int *) * n);
      27    if (!p)
      28      return;
      29  
      30    for (i = 0; i < n; ++i)
      31      p[i] = __builtin_malloc (sizeof (i));
      32  
      33    for (i = 0; i < n; ++i)
      34      __builtin_free (p [i]);
      35  
      36    __builtin_free (p);
      37  }
      38  
      39  void
      40  test_3 (int **p, int n)
      41  {
      42    int i;
      43    for (i = 0; i < n; ++i)
      44      p[i] = __builtin_malloc (sizeof (i));
      45  }
      46  
      47  void
      48  test_4 (void **p, int n)
      49  {
      50    int i;
      51    for (i = 0; i < n; ++i)
      52      __builtin_free (p[i]);
      53  }