blob: 6b950ca23a99d37d526c9ed5c651c6931537630d [file] [log] [blame]
#include <string.h>
#include <stdlib.h>
extern void requires_nonnull (void *ptr)
__attribute__((nonnull));
void test_1 (const char *s)
{
char *p = strdup (s); /* { dg-message "allocated here" } */
} /* { dg-warning "leak of 'p'" } */
void test_2 (const char *s)
{
char *p = strdup (s);
free (p);
}
void test_3 (const char *s)
{
char *p = strdup (s); /* { dg-message "this call could return NULL" } */
requires_nonnull (p); /* { dg-warning "use of possibly-NULL 'p'" } */
}