2009-12-16 06:01:24 +08:00
|
|
|
// RUN: %clang -Xclang -verify -fsyntax-only %s
|
|
|
|
// RUN: %clang -emit-llvm -S -o %t %s
|
2009-08-10 04:07:29 +08:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-08-15 08:51:46 +08:00
|
|
|
int no_vars __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
|
2009-08-10 04:07:29 +08:00
|
|
|
|
2009-08-15 08:51:46 +08: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-15 06:03:27 +08:00
|
|
|
int * returns_intptr(void) __attribute((malloc)); // no-warning
|
2009-08-10 06:36:29 +08:00
|
|
|
typedef int * iptr;
|
2009-08-15 06:03:27 +08:00
|
|
|
iptr returns_iptr (void) __attribute((malloc)); // no-warning
|
|
|
|
|
2009-08-15 08:51:46 +08: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-10 06:36:29 +08:00
|
|
|
|
2009-08-10 04:07:29 +08:00
|
|
|
__attribute((malloc))
|
2009-08-15 06:03:27 +08:00
|
|
|
void * xalloc(unsigned n) { return malloc(n); } // no-warning
|
2009-11-08 09:45:36 +08:00
|
|
|
// RUN: grep 'define noalias .* @xalloc(' %t
|
2009-08-10 04:07:29 +08:00
|
|
|
|
2009-08-12 06:46:25 +08:00
|
|
|
#define malloc_like __attribute((__malloc__))
|
|
|
|
void * xalloc2(unsigned) malloc_like;
|
2009-08-10 04:07:29 +08:00
|
|
|
void * xalloc2(unsigned n) { return malloc(n); }
|
|
|
|
// RUN: grep 'define noalias .* @xalloc2(' %t
|
|
|
|
|