66 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wno-strict-prototypes -verify %s2 3void f() {4 int *ptr = malloc(sizeof(int) * 10); // expected-error{{call to undeclared library function 'malloc' with type}} \5 // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \6 // expected-note{{'malloc' is a builtin with type 'void *}}7}8 9void *alloca(__SIZE_TYPE__); // redeclaration okay10 11int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \12 // expected-note{{'calloc' is a builtin with type 'void *}}13 14 15void g(int malloc) { // okay: these aren't functions16 int calloc = 1;17}18 19void h() {20 int malloc(int); // expected-warning{{incompatible redeclaration of library function 'malloc'}}21 int strcpy(int); // expected-warning{{incompatible redeclaration of library function 'strcpy'}} \22 // expected-note{{'strcpy' is a builtin with type 'char *(char *, const char *)'}}23}24 25void f2() {26 fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \27 expected-error {{call to undeclared function 'fprintf'; ISO C99 and later do not support implicit function declarations}}28}29 30// PR289231void __builtin_object_size(); // expected-error{{conflicting types}} \32// expected-note{{'__builtin_object_size' is a builtin with type}}33 34int a[10];35 36int f0() {37 return __builtin_object_size(&a); // expected-error {{too few arguments to function}}38}39 40void * realloc(void *p, int size) { // expected-warning{{incompatible redeclaration of library function 'realloc'}} \41// expected-note{{'realloc' is a builtin with type 'void *(void *,}}42 return p;43}44 45// PR385546void snprintf(); // expected-warning{{incompatible redeclaration of library function 'snprintf'}} \47 // expected-note{{'snprintf' is a builtin}}48 49int50main(int argc, char *argv[])51{52 snprintf();53}54 55void snprintf() { }56 57void longjmp();58 59extern float fmaxf(float, float);60 61struct __jmp_buf_tag {};62void sigsetjmp(struct __jmp_buf_tag[1], int);63 64// PR4069265void pthread_create(); // no warning expected66