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