1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
3
f()4 void f() {
5 int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
6 // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
7 // expected-note{{'malloc' is a builtin with type 'void *}}
8 }
9
10 void *alloca(__SIZE_TYPE__); // redeclaration okay
11
12 int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \
13 // expected-note{{'calloc' is a builtin with type 'void *}}
14
15
g(int malloc)16 void g(int malloc) { // okay: these aren't functions
17 int calloc = 1;
18 }
19
h()20 void h() {
21 int malloc(int); // expected-warning{{incompatible redeclaration of library function 'malloc'}}
22 int strcpy(int); // expected-warning{{incompatible redeclaration of library function 'strcpy'}} \
23 // expected-note{{'strcpy' is a builtin with type 'char *(char *, const char *)'}}
24 }
25
f2()26 void f2() {
27 fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \
28 expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
29 }
30
31 // PR2892
32 void __builtin_object_size(); // expected-error{{conflicting types}} \
33 // expected-note{{'__builtin_object_size' is a builtin with type}}
34
35 int a[10];
36
f0()37 int f0() {
38 return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
39 }
40
realloc(void * p,int size)41 void * realloc(void *p, int size) { // expected-warning{{incompatible redeclaration of library function 'realloc'}} \
42 // expected-note{{'realloc' is a builtin with type 'void *(void *,}}
43 return p;
44 }
45
46 // PR3855
47 void snprintf(); // expected-warning{{incompatible redeclaration of library function 'snprintf'}} \
48 // expected-note{{'snprintf' is a builtin}}
49
50 int
main(int argc,char * argv[])51 main(int argc, char *argv[])
52 {
53 snprintf();
54 }
55
snprintf()56 void snprintf() { }
57
58 // PR8316
59 void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}}
60
61 extern float fmaxf(float, float);
62
63 struct __jmp_buf_tag {};
64 void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header <setjmp.h>}}
65
66 // CHECK: FunctionDecl {{.*}} <line:[[@LINE-2]]:1, col:44> col:6 sigsetjmp '
67 // CHECK-NOT: FunctionDecl
68 // CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
69