blob: e9b0556f3e5854cc1460db97849fe0c242e642a8 [file] [log] [blame]
Douglas Gregor3e41d602009-02-13 23:20:09 +00001// RUN: clang -fsyntax-only -verify %s
2void f() {
3 int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring C library function 'malloc' with type}} \
4 // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
5 // expected-note{{'malloc' was implicitly declared here with type 'void *}}
6}
7
8void *alloca(__SIZE_TYPE__); // redeclaration okay
9
10int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-error{{conflicting types for 'calloc'}} \
11 // expected-note{{'calloc' was implicitly declared here with type 'void *}}
12
13
14void g(int malloc) { // okay: these aren't functions
15 int calloc = 1;
16}
17
18void h() {
19 int malloc(int); // expected-error{{conflicting types for 'malloc'}}
20 int strcpy(int); // expected-error{{conflicting types for 'strcpy'}} \
21 // expected-note{{'strcpy' was implicitly declared here with type 'char *(char *, char const *)'}}
22}
Douglas Gregor370ab3f2009-02-14 01:52:53 +000023
24void f2() {
25 fprintf(0, "foo"); // expected-error{{implicit declaration of 'fprintf' requires inclusion of the header <stdio.h>}}
26}