2009-08-09 20:07:29 +00:00
|
|
|
// RUN: clang-cc -verify -fsyntax-only %s &&
|
|
|
|
// RUN: clang-cc -emit-llvm -o %t %s &&
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-08-15 00:51:46 +00:00
|
|
|
int no_vars __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
|
2009-08-09 20:07:29 +00:00
|
|
|
|
2009-08-15 00:51:46 +00:00
|
|
|
void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
|
|
|
|
int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
|
2009-08-14 22:03:27 +00:00
|
|
|
int * returns_intptr(void) __attribute((malloc)); // no-warning
|
2009-08-09 22:36:29 +00:00
|
|
|
typedef int * iptr;
|
2009-08-14 22:03:27 +00:00
|
|
|
iptr returns_iptr (void) __attribute((malloc)); // no-warning
|
|
|
|
|
2009-08-15 00:51:46 +00:00
|
|
|
__attribute((malloc)) void *(*f)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
|
|
|
|
__attribute((malloc)) int (*g)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
|
2009-08-09 22:36:29 +00:00
|
|
|
|
2009-08-09 20:07:29 +00:00
|
|
|
__attribute((malloc))
|
2009-08-14 22:03:27 +00:00
|
|
|
void * xalloc(unsigned n) { return malloc(n); } // no-warning
|
2009-08-09 20:07:29 +00:00
|
|
|
// RUN: grep 'define noalias .* @xalloc(' %t &&
|
|
|
|
|
2009-08-11 22:46:25 +00:00
|
|
|
#define malloc_like __attribute((__malloc__))
|
|
|
|
void * xalloc2(unsigned) malloc_like;
|
2009-08-09 20:07:29 +00:00
|
|
|
void * xalloc2(unsigned n) { return malloc(n); }
|
|
|
|
// RUN: grep 'define noalias .* @xalloc2(' %t
|
|
|
|
|