summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/builtins.c
Commit message (Collapse)AuthorAgeFilesLines
* Add __sync_fetch_and_nand (again)Hal Finkel2014-10-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to GCC 4.4, __sync_fetch_and_nand was implemented as: { tmp = *ptr; *ptr = ~tmp & value; return tmp; } but this was changed in GCC 4.4 to be: { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } in response to this change, support for sync_fetch_and_nand (and sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code depending on the old semantics. However, at this point: 1. Many years have passed, and the amount of code relying on the old semantics is likely smaller. 2. Through the work of many contributors, all LLVM backends have been updated such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process was complete July of 2014 (added to the release notes in r212635). 3. The lack of this intrinsic is now a needless impediment to porting codes from GCC to Clang (I've now seen several examples of this). It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC 4.2). To compensate for this, and to address the original concern regarding code relying on the old semantics, I've added a warning that specifically details the fact that the semantics have changed and that we provide the newer semantics. Fixes PR8842. llvm-svn: 218905
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-181-2/+23
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-121-5/+25
| | | | | | | | for __builtin___strlcpy_chk/__builtin___strlcat_chk. Patch by Jacques Fortier with monir change by me and addition of test. rdar://18259539 llvm-svn: 217700
* Add __builtin_operator_new and __builtin_operator_delete, which act like callsRichard Smith2014-06-031-0/+5
| | | | | | | to the normal non-placement ::operator new and ::operator delete, but allow optimizations like new-expressions and delete-expressions do. llvm-svn: 210137
* Only provide MS builtins when -fms-extensions is onReid Kleckner2013-11-131-0/+6
| | | | | | | | | | | We already have builtins that are only available in GNU mode, so this mirrors that. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2128 llvm-svn: 194615
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-1/+1
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Add tests to check recent changes to some builtins.Bill Wendling2012-12-181-0/+15
| | | | llvm-svn: 170458
* Tweak wording and add diagnostic groups to misc diagnostics.Eli Friedman2012-11-021-1/+1
| | | | llvm-svn: 167274
* Avoid multiple atomic builtin declaration.Abramo Bagnara2012-09-221-0/+14
| | | | llvm-svn: 164454
* Add -Wstring-plus-int, which warns on "str" + int and int + "str".Nico Weber2012-03-021-1/+1
| | | | | | | | It doesn't warn if the integer is known at compile time and within the bounds of the string. Discussion: http://comments.gmane.org/gmane.comp.compilers.clang.scm/47203 llvm-svn: 151943
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Replace the implementation of __builtin_constant_p (which was based on the GCCRichard Smith2011-12-091-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | documentation) with one based on what GCC's __builtin_constant_p is actually intended to do (discovered by asking a friendly GCC developer). In particular, an expression which folds to a pointer is now only considered to be a "constant" by this builtin if it refers to the first character in a string literal. This fixes a rather subtle wrong-code issue when building with glibc. Given: const char cs[4] = "abcd"; int f(const char *p) { return strncmp(p, cs, 4); } ... the macro magic for strncmp produces a (potentially crashing) call to strlen(cs), because it expands to an expression starting with: __builtin_constant_p(cs) && strlen(cs) < 4 ? /* ... */ Under the secret true meaning of __builtin_constant_p, this is guaranteed to be safe! llvm-svn: 146236
* Suggest typo corrections for implicit function declarations.Hans Wennborg2011-12-061-2/+2
| | | | | | | A mistyped function call becomes an inmplicit function declaration in C. Suggest typo correction when one can be found. llvm-svn: 145930
* Remove warning for null characters in CFString literals. Clang handles them ↵Ted Kremenek2011-03-151-1/+1
| | | | | | | | just fine, and GCC 4.2 doesn't warn here either. We added this warning back in 2007 when we were comparing against GCC 4.0. llvm-svn: 127704
* zap trailing whitespaceGabor Greif2010-10-151-5/+5
| | | | llvm-svn: 116572
* fix PR7885, rejecting invalid uses of __builtin_constant_p.Chris Lattner2010-10-121-0/+7
| | | | llvm-svn: 116317
* Have Sema check for validity of CGString literalFariborz Jahanian2010-09-071-1/+1
| | | | | | instead of asserting in IRGen. Fixes radar 8390459. llvm-svn: 113253
* Implement __builtin_printf, __builtin_fprintf. Fixes <rdar://problem/8336581>.Douglas Gregor2010-08-251-0/+5
| | | | llvm-svn: 112049
* Make the pointer arguments to the __sync_* builtins pointers toDouglas Gregor2010-07-281-0/+6
| | | | | | volatile-qualified types. Fixes <rdar://problem/8228293>. llvm-svn: 109618
* Mark __builtin_eh_return as noreturn. Patch by Dimitry Andric.Benjamin Kramer2010-07-261-0/+4
| | | | llvm-svn: 109452
* Improve the representation of the atomic builtins in a few ways. First, we makeChandler Carruth2010-07-181-0/+5
| | | | | | | | | | | | | | | their call expressions synthetically have the "deduced" types based on their first argument. We only insert conversions in the AST for arguments whose values require conversion to match the value type expected. This keeps PR7600 closed by maintaining the return type, but avoids assertions due to unexpected implicit casts making the type unsigned (test case added from Daniel). The magic is moved into the codegen for the atomic builtin which inserts the casts as needed at the IR level to raise the type to an integer suitable for the LLVM intrinsic. This shouldn't cause any real change in functionality, but now we can make the builtin be more truly polymorphic. llvm-svn: 108638
* Fix PR7600, and correctly convert the result of an atomic builtin to theChandler Carruth2010-07-091-1/+4
| | | | | | | | | expected value type. This is necessary as the builtin is internally represented as only operating on integral types. Also, add a FIXME to add support for floating point value types. llvm-svn: 108002
* Remove the argument number from the constant integer diagnostic.Eric Christopher2010-04-191-1/+1
| | | | | | Update all of the testcases accordingly. llvm-svn: 101795
* Consolidate most of the integer constant expression builtin requirementEric Christopher2010-04-171-1/+1
| | | | | | | | checking into a single function and use that throughout. Remove some now unnecessary diagnostics and update tests with now more accurate diagnostics. llvm-svn: 101610
* testcase for previous patch!Chris Lattner2009-12-301-4/+5
| | | | llvm-svn: 92317
* 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
* Provide a custom diagnostic when code tries to use an unknown builtinDouglas Gregor2009-09-281-0/+4
| | | | llvm-svn: 83014
* builtin_trap should be noreturn, this fixes PR5062, patch byChris Lattner2009-09-261-0/+5
| | | | | | Roman Divacky! llvm-svn: 82876
* implement support for __builtin_eh_return_data_regno on x86-32 and x86-64.Chris Lattner2009-09-231-0/+10
| | | | | | This implements PR5034 and rdar://6836445. llvm-svn: 82614
* Implement __builtin_unreachable(), a GCC 4.5 extension.Chris Lattner2009-09-211-0/+11
| | | | llvm-svn: 82433
* Prep for new warning.Mike Stump2009-07-221-1/+1
| | | | llvm-svn: 76709
* Test changes to account for removed builtins.Eli Friedman2009-06-061-9/+0
| | | | llvm-svn: 73004
* Fix the atomics sema code to convert operands to the argument typesChris Lattner2009-05-081-1/+1
| | | | | | | | | of the underlying _N builtin, not the the type of the pointee of the actual type. This ensures that atomics involving pointers end up using the correct integer type when they are resolved, avoiding aborts in codegen. llvm-svn: 71218
* reimplement __sync_* builtins to be variadic and to follow the sameChris Lattner2009-05-081-2/+12
| | | | | | | | | semantic rules that gcc and icc use. This implements the variadic and concrete versions as builtins and has sema do the disambiguation. There are probably a bunch of details to finish up but this seems like a large monotonic step forward :) llvm-svn: 71212
* Simplify the scheme used for keywords, and change the classification Eli Friedman2009-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scheme to be more useful. The new scheme introduces a set of categories that should be more readable, and also reflects what we want to consider as an extension more accurately. Specifically, it makes the "what is a keyword" determination accurately reflect whether the keyword is a GNU or Microsoft extension. I also introduced separate flags for keyword aliases; this is useful because the classification of the aliases is mostly unrelated to the classification of the original keyword. This patch treats anything that's in the implementation namespace (prefixed with "__", or "_X" where "X" is any upper-case letter) as a keyword without marking it as an extension. This is consistent with the standards in that an implementation is allowed to define arbitrary extensions in the implementation namespace without violating the standard. This gets rid of all the nasty "extension used" warnings for stuff like __attribute__ in -pedantic mode. We still warn for extensions outside of the the implementation namespace, like typeof. If someone wants to implement -Wextensions or something like that, we could add additional information to the keyword table. This also removes processing for the unused "Boolean" language option; such an extension isn't supported on any other C implementation, so I don't see any point to adding it. The changes to test/CodeGen/inline.c are required because previously, we weren't actually disabling the "inline" keyword in -std=c89 mode. I'll remove Boolean and NoExtensions from LangOptions in a follow-up commit. llvm-svn: 70281
* We no longer expect an warning as this is now valid.Mike Stump2009-04-021-1/+1
| | | | llvm-svn: 68263
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* merge some simple call diagnostics.Chris Lattner2008-11-211-1/+1
| | | | llvm-svn: 59831
* Fix this test on non-X86 platforms.Eli Friedman2008-05-251-1/+2
| | | | llvm-svn: 51552
* Fix rdar://5905347 a crash on invalid builtin, due to theChris Lattner2008-05-051-0/+9
| | | | | | params not getting installed for builtins when synthesized. llvm-svn: 50676
* add comments for the various AssignConvertType's, and split int->pointer ↵Chris Lattner2008-01-041-1/+1
| | | | | | from pointer->int. llvm-svn: 45591
* Merge all the 'assignment' diagnostic code into one routine, decloning Chris Lattner2008-01-041-3/+2
| | | | | | | | | | | | | it from several places. This merges the diagnostics, making them more uniform and fewer in number. This also simplifies and cleans up the code. Some highlights: 1. This removes a bunch of very-similar diagnostics. 2. This renames AssignmentCheckResult -> AssignConvertType 3. This merges PointerFromInt + IntFromPointer which were always treated the same. 4. This updates a bunch of test cases that have minor changes to the produced diagnostics. llvm-svn: 45589
* implement semantic analysis for __builtin_islessequal and friends.Chris Lattner2007-12-201-0/+33
llvm-svn: 45239
OpenPOWER on IntegriCloud