brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · a431aa4 Raw
29 lines · c
1// RUN: %clang_cc1 -verify -fsyntax-only %s2// RUN: %clang_cc1 -emit-llvm -o %t %s3 4#include <stddef.h>5 6// Declare malloc here explicitly so we don't depend on system headers.7void * malloc(size_t) __attribute((malloc));8 9int no_vars __attribute((malloc)); // expected-warning {{attribute only applies to functions}}10 11void  returns_void  (void) __attribute((malloc)); // expected-warning {{attribute only applies to return values that are pointers}}12int   returns_int   (void) __attribute((malloc)); // expected-warning {{attribute only applies to return values that are pointers}}13int * returns_intptr(void) __attribute((malloc)); // no-warning14typedef int * iptr;15iptr  returns_iptr  (void) __attribute((malloc)); // no-warning16 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}}19 20__attribute((malloc))21void * xalloc(unsigned n) { return malloc(n); } // no-warning22// RUN: grep 'define .*noalias .* @xalloc(' %t %t23 24#define malloc_like __attribute((__malloc__))25void * xalloc2(unsigned) malloc_like;26void * xalloc2(unsigned n) { return malloc(n); }27// RUN: grep 'define .*noalias .* @xalloc2(' %t %t28 29