(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
malloc-ipa-13a.c
       1  /* { dg-additional-options "-fanalyzer-verbosity=1" } */
       2  
       3  #include <stdlib.h>
       4  
       5  void
       6  calls_free (void *victim)
       7  {
       8    free (victim); /* { dg-warning "double-'free' of 'victim'" } */
       9  }
      10  
      11  extern void do_stuff (void);
      12  
      13  struct foo
      14  {
      15    void *m_p;
      16  };
      17  
      18  static void *  __attribute__((noinline))
      19  test_a (struct foo f)
      20  {
      21    do_stuff ();
      22  
      23    calls_free (f.m_p);
      24  
      25    do_stuff ();
      26  
      27    return f.m_p;
      28  }
      29  
      30  void test_b (void *p)
      31  {
      32    void *q;
      33    struct foo f;
      34    f.m_p = p;
      35    q = test_a (f);
      36    calls_free (q); /* { dg-message "passing freed pointer 'q' in call to 'calls_free' from 'test_b'" } */
      37    do_stuff ();
      38  }