Ryan Flynn | 31af091 | 2009-08-09 20:07:29 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -verify -fsyntax-only %s && |
| 2 | // RUN: clang-cc -emit-llvm -o %t %s && |
| 3 | |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | int no_vars __attribute((malloc)); // expected-warning {{only applies to function types}} |
| 7 | |
Ryan Flynn | 6a7fda0 | 2009-08-09 22:36:29 +0000 | [diff] [blame^] | 8 | void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning pointer type}} |
| 9 | int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning pointer type}} |
| 10 | int * returns_intptr(void) __attribute((malloc)); |
| 11 | typedef int * iptr; |
| 12 | iptr returns_iptr (void) __attribute((malloc)); |
| 13 | |
Ryan Flynn | 31af091 | 2009-08-09 20:07:29 +0000 | [diff] [blame] | 14 | __attribute((malloc)) |
| 15 | void * xalloc(unsigned n) { return malloc(n); } |
| 16 | // RUN: grep 'define noalias .* @xalloc(' %t && |
| 17 | |
| 18 | #define __malloc_like __attribute((__malloc__)) |
| 19 | void * xalloc2(unsigned) __malloc_like; |
| 20 | void * xalloc2(unsigned n) { return malloc(n); } |
| 21 | // RUN: grep 'define noalias .* @xalloc2(' %t |
| 22 | |