1 /* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* hppa*-*-hpux* *-*-mingw* *-*-vxworks* } } */
6 extern void requires_nonnull (void *ptr
)
7 __attribute__((nonnull
));
9 void test_1 (const char *s
)
11 char *p
= strndup (s
, 42); /* { dg-message "allocated here" } */
12 } /* { dg-warning "leak of 'p'" } */
14 void test_2 (const char *s
)
16 char *p
= strndup (s
, 42);
19 void test_3 (const char *s
)
21 char *p
= strndup (s
, 42); /* { dg-message "this call could return NULL" } */
22 requires_nonnull (p
); /* { dg-warning "use of possibly-NULL 'p'" } */