diff options
Diffstat (limited to 'test/Sema/implicit-builtin-decl.c')
-rw-r--r-- | test/Sema/implicit-builtin-decl.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c new file mode 100644 index 0000000000..3faef0b719 --- /dev/null +++ b/test/Sema/implicit-builtin-decl.c @@ -0,0 +1,22 @@ +// RUN: clang -fsyntax-only -verify %s +void f() { + int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring C library function 'malloc' with type}} \ + // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \ + // expected-note{{'malloc' was implicitly declared here with type 'void *}} +} + +void *alloca(__SIZE_TYPE__); // redeclaration okay + +int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-error{{conflicting types for 'calloc'}} \ + // expected-note{{'calloc' was implicitly declared here with type 'void *}} + + +void g(int malloc) { // okay: these aren't functions + int calloc = 1; +} + +void h() { + int malloc(int); // expected-error{{conflicting types for 'malloc'}} + int strcpy(int); // expected-error{{conflicting types for 'strcpy'}} \ + // expected-note{{'strcpy' was implicitly declared here with type 'char *(char *, char const *)'}} +} |