Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/attr-malloc-misuses.c

raw
1 extern void free (void *);
2
3 int not_a_fn __attribute__ ((malloc (free))); /* { dg-warning "'malloc' attribute ignored; valid only for functions" } */
4
5 void void_return (void) __attribute__ ((malloc(free))); /* { dg-warning "'malloc' attribute ignored on functions returning 'void'" } */
6
7 void test_void_return (void)
8 {
9 void_return ();
10 }
11
12 extern void void_args (void); /* { dg-message "declared here" } */
13 void *has_malloc_with_void_args (void)
14 __attribute__ ((malloc(void_args))); /* { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'void'" } */
15
16 extern void no_args (); /* { dg-message "declared here" } */
17 void *has_malloc_with_no_args (void)
18 __attribute__ ((malloc(no_args))); /* { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument" } */