attr-malloc.c revision 76168e289ca4b307259e3bc9b3353f03b05bb6b9
1// RUN: clang-cc -verify -fsyntax-only %s &&
2// RUN: clang-cc -emit-llvm -o %t %s &&
3
4#include <stdlib.h>
5
6int no_vars __attribute((malloc)); // expected-warning {{only applies to function types}}
7
8__attribute((malloc))
9void * xalloc(unsigned n) { return malloc(n); }
10// RUN: grep 'define noalias .* @xalloc(' %t &&
11
12#define __malloc_like __attribute((__malloc__))
13void * xalloc2(unsigned) __malloc_like;
14void * xalloc2(unsigned n) { return malloc(n); }
15// RUN: grep 'define noalias .* @xalloc2(' %t
16
17