1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
f()3 void f() {
4 int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring 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
9 void *alloca(__SIZE_TYPE__); // redeclaration okay
10
11 int *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
g(int malloc)15 void g(int malloc) { // okay: these aren't functions
16 int calloc = 1;
17 }
18
h()19 void 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
f2()25 void f2() {
26 fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \
27 expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
28 }
29
30 // PR2892
31 void __builtin_object_size(); // expected-error{{conflicting types}} \
32 // expected-note{{'__builtin_object_size' is a builtin with type}}
33
34 int a[10];
35
f0()36 int f0() {
37 return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
38 }
39
realloc(void * p,int size)40 void * 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 // PR3855
46 void snprintf(); // expected-warning{{incompatible redeclaration of library function 'snprintf'}} \
47 // expected-note{{'snprintf' is a builtin}}
48
49 int
main(int argc,char * argv[])50 main(int argc, char *argv[])
51 {
52 snprintf();
53 }
54
snprintf()55 void snprintf() { }
56
57 void longjmp();
58
59 extern float fmaxf(float, float);
60
61 struct __jmp_buf_tag {};
62 void sigsetjmp(struct __jmp_buf_tag[1], int);
63
64 // PR40692
65 void pthread_create(); // no warning expected
66