view gcc/testsuite/gcc.dg/analyzer/malloc-ipa-13.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-additional-options "-fanalyzer-verbosity=1" } */

#include <stdlib.h>

void
calls_free (void *victim)
{
  free (victim); /* { dg-warning "double-'free' of 'victim'" } */
}

extern void do_stuff (void);

struct foo
{
  void *m_p;
};

void test (struct foo f)
{
  do_stuff ();

  calls_free (f.m_p);

  do_stuff ();

  calls_free (f.m_p); /* { dg-message "passing freed pointer '<unknown>' in call to 'calls_free' from 'test'" } */
  // TODO: something better than '<unknown>'

  do_stuff ();
}