[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / attr-malloc.c
bloba431aa43969d75848dd9d62eff6e8da7a3b28850
1 // RUN: %clang_cc1 -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -emit-llvm -o %t %s
4 #include <stddef.h>
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
14 typedef int * iptr;
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}}
20 __attribute((malloc))
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