1 // RUN: %clang_cc1 -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -emit-llvm -o %t %s
6 // Declare malloc here explicitly so we don't depend on system headers.
7 void * malloc(size_t) __attribute((malloc
));
9 int no_vars
__attribute((malloc
)); // expected-warning {{attribute only applies to functions}}
11 void returns_void (void) __attribute((malloc
)); // expected-warning {{attribute only applies to return values that are pointers}}
12 int returns_int (void) __attribute((malloc
)); // expected-warning {{attribute only applies to return values that are pointers}}
13 int * returns_intptr(void) __attribute((malloc
)); // no-warning
15 iptr
returns_iptr (void) __attribute((malloc
)); // no-warning
17 __attribute((malloc
)) void *(*f
)(void); // expected-warning{{attribute only applies to functions}}
18 __attribute((malloc
)) int (*g
)(void); // expected-warning{{attribute only applies to functions}}
21 void * xalloc(unsigned n
) { return malloc(n
); } // no-warning
22 // RUN: grep 'define .*noalias .* @xalloc(' %t %t
24 #define malloc_like __attribute((__malloc__))
25 void * xalloc2(unsigned) malloc_like
;
26 void * xalloc2(unsigned n
) { return malloc(n
); }
27 // RUN: grep 'define .*noalias .* @xalloc2(' %t %t