summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/implicit-builtin-decl.c
Commit message (Collapse)AuthorAgeFilesLines
* [Fix] Customize warnings for missing built-in typesJohannes Doerfert2019-07-311-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we detect a built-in declaration for which we cannot derive a type matching the pattern in the Builtins.def file, we currently emit a warning that the respective header is needed. However, this is not necessarily the behavior we want as it has no connection to the location of the declaration (which can actually be in the header in question). Instead, this warning is generated - if we could not build the type for the pattern on file (for some reason). Here we should make the reason explicit. The actual problem is otherwise circumvented as the warning is misleading, see [0] for an example. - if we could not build the type for the pattern because we do not have a type on record, possible since D55483, we should not emit any warning. See [1] for a legitimate problem. This patch address both cases. For the "setjmp" family a new warning is introduced and for built-ins without type on record, so far "pthread_create", we do not emit the warning anymore. Also see: PR40692 [0] https://lkml.org/lkml/2019/1/11/718 [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235583 Differential Revision: https://reviews.llvm.org/D58091 llvm-svn: 367387
* Consolidate header inclusion diagnosticsAlp Toker2014-07-111-1/+1
| | | | | | | Make argument orders match, unify diagnostic IDs and reword the message to be a little less saccharine. llvm-svn: 212845
* Add the location of Decls to ast dump.David Blaikie2014-04-021-1/+1
| | | | | | | | | While investigating some debug info issues, Eric and I came across a particular template case where the location of a decl was quite different from the range of the same decl. It might've been rather helpful if the dumper had actually showed us this. llvm-svn: 205396
* Don't forget about a builtin if we're about to redeclare it and we couldn'tRichard Smith2014-01-221-0/+9
| | | | | | | | | | | | | create an implicit declaration of it (because some type it depends on is unavailable). This had the effect of causing us to not implicitly give it the right attributes. It turns out that glibc's __sigsetjmp is declared before sigjmp_buf is declared, and this resulted in us not implicitly giving it __attribute__((returns_twice)), which in turn resulted in miscompiles in any C code calling glibc's sigsetjmp. (See also the vaguely-related sourceware.org/PR4662.) llvm-svn: 199850
* Fix fmin*/fmax* library builtin signatures.Douglas Gregor2012-05-081-0/+2
| | | | llvm-svn: 156396
* Remove the "C" in "implicitly declaring C library function" diagnosticJean-Daniel Dupas2012-01-271-1/+1
| | | | | | because all functions are not C functions (i.e. NSLog). llvm-svn: 149150
* When we attempt to create a built-in that involves a library type weDouglas Gregor2011-01-031-1/+4
| | | | | | | | | don't have access to (e.g., fprintf, which needs the library type FILE), fail with a warning and forget about the builtin entirely. Previously, we would actually provide an error, which breaks autoconf's super-lame checks for fprintf, longjmp, etc. Fixes PR8316. llvm-svn: 122744
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-1/+1
| | | | | | | which is should have done from the beginning. As usual, the most fun with this sort of change is updating all the testcases. llvm-svn: 113090
* add a bunch of missing prototypes to testsChris Lattner2010-01-091-1/+2
| | | | llvm-svn: 93072
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix a couple of tests.Eli Friedman2009-03-241-1/+1
| | | | llvm-svn: 67592
* Fix PR3855. When we encounter an incompatible redeclaration of aDouglas Gregor2009-03-231-4/+16
| | | | | | | | library function, accept this declaration and pretend that we do not know that this is a library function. autoconf depends on this (broken) behavior. llvm-svn: 67541
* Fix test on platforms where size_t != unsigned long.Eli Friedman2009-02-181-1/+1
| | | | llvm-svn: 64867
* Remove the error about redefining library functions. It's causing tooDouglas Gregor2009-02-171-3/+1
| | | | | | much pain when compiling the Linux kernel (PR3592). llvm-svn: 64767
* Static variables and functions won't collide with standard libraryDouglas Gregor2009-02-171-1/+0
| | | | | | | functions, so if we're declaring a static we should implicitly declare a library function by the same name (e.g., malloc, strdup). Fixes PR3592. llvm-svn: 64736
* Adopt a more principled approach to invalid declarations:Douglas Gregor2009-02-161-6/+24
| | | | | | | | | | | | | | | | | | | | | | | - If a declaration is an invalid redeclaration of an existing name, complain about the invalid redeclaration then avoid adding it to the AST (we can still parse the definition or initializer, if any). - If the declaration is invalid but there is no prior declaration with that name, introduce the invalid declaration into the AST (for later error recovery). - If the declaration is an invalid redeclaration of a builtin that starts with __builtin_, we produce an error and drop the redeclaration. If it is an invalid redeclaration of a library builtin (e.g., malloc, printf), warn (don't error!) and drop the redeclaration. If a user attempts to define a builtin, produce an error and (if it's a library builtin like malloc) suggest -ffreestanding. This addresses <rdar://problem/6097585> and PR2892. However, PR3588 is still going to cause some problems when builtins are redeclared without a prototype. llvm-svn: 64639
* Make it possible for builtins to expression FILE* arguments, so thatDouglas Gregor2009-02-141-0/+4
| | | | | | | | we can define builtins such as fprintf, vfprintf, and __builtin___fprintf_chk. Give a nice error message when we need to implicitly declare a function like fprintf. llvm-svn: 64526
* Implicitly declare certain C library functions (malloc, strcpy, memmove,Douglas Gregor2009-02-131-0/+22
etc.) when we perform name lookup on them. This ensures that we produce the correct signature for these functions, which has two practical impacts: 1) When we're supporting the "implicit function declaration" feature of C99, these functions will be implicitly declared with the right signature rather than as a function returning "int" with no prototype. See PR3541 for the reason why this is important (hint: GCC always predeclares these functions). 2) If users attempt to redeclare one of these library functions with an incompatible signature, we produce a hard error. This patch does a little bit of work to give reasonable error messages. For example, when we hit case #1 we complain that we're implicitly declaring this function with a specific signature, and then we give a note that asks the user to include the appropriate header (e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In case #2, we show the type of the implicit builtin that was incorrectly declared, so the user can see the problem. We could do better here: for example, when displaying this latter error message we say something like: 'strcpy' was implicitly declared here with type 'char *(char *, char const *)' but we should really print out a fake code line showing the declaration, like this: 'strcpy' was implicitly declared here as: char *strcpy(char *, char const *) This would also be good for printing built-in candidates with C++ operator overloading. The set of C library functions supported by this patch includes all functions from the C99 specification's <stdlib.h> and <string.h> that (a) are predefined by GCC and (b) have signatures that could cause codegen issues if they are treated as functions with no prototype returning and int. Future work could extend this set of functions to other C library functions that we know about. llvm-svn: 64504
OpenPOWER on IntegriCloud