aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/builtins.c
AgeCommit message (Collapse)Author
2012-12-18Add tests to check recent changes to some builtins.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170458 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02Tweak wording and add diagnostic groups to misc diagnostics.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167274 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-22Avoid multiple atomic builtin declaration.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164454 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02Add -Wstring-plus-int, which warns on "str" + int and int + "str".Nico Weber
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151943 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-15Modify how the -verify flag works. Currently, the verification string andRichard Trieu
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) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146619 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-09Replace the implementation of __builtin_constant_p (which was based on the GCCRichard Smith
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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146236 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-06Suggest typo corrections for implicit function declarations.Hans Wennborg
A mistyped function call becomes an inmplicit function declaration in C. Suggest typo correction when one can be found. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-15Remove warning for null characters in CFString literals. Clang handles them ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127704 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-15zap trailing whitespaceGabor Greif
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12fix PR7885, rejecting invalid uses of __builtin_constant_p.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116317 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07Have Sema check for validity of CGString literalFariborz Jahanian
instead of asserting in IRGen. Fixes radar 8390459. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113253 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25Implement __builtin_printf, __builtin_fprintf. Fixes <rdar://problem/8336581>.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112049 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-28Make the pointer arguments to the __sync_* builtins pointers toDouglas Gregor
volatile-qualified types. Fixes <rdar://problem/8228293>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26Mark __builtin_eh_return as noreturn. Patch by Dimitry Andric.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109452 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-18Improve the representation of the atomic builtins in a few ways. First, we makeChandler Carruth
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09Fix PR7600, and correctly convert the result of an atomic builtin to theChandler Carruth
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19Remove the argument number from the constant integer diagnostic.Eric Christopher
Update all of the testcases accordingly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Consolidate most of the integer constant expression builtin requirementEric Christopher
checking into a single function and use that throughout. Remove some now unnecessary diagnostics and update tests with now more accurate diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101610 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30testcase for previous patch!Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar
- 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28Provide a custom diagnostic when code tries to use an unknown builtinDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83014 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26builtin_trap should be noreturn, this fixes PR5062, patch byChris Lattner
Roman Divacky! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82876 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23implement support for __builtin_eh_return_data_regno on x86-32 and x86-64.Chris Lattner
This implements PR5034 and rdar://6836445. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82614 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21Implement __builtin_unreachable(), a GCC 4.5 extension.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82433 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22Prep for new warning.Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76709 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06Test changes to account for removed builtins.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73004 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-08Fix the atomics sema code to convert operands to the argument typesChris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71218 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-08reimplement __sync_* builtins to be variadic and to follow the sameChris Lattner
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 :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71212 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28Simplify the scheme used for keywords, and change the classification Eli Friedman
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70281 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02We no longer expect an warning as this is now valid.Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24Rename clang to clang-cc.Daniel Dunbar
Tests and drivers updated, still need to shuffle dirs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21merge some simple call diagnostics.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59831 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-25Fix this test on non-X86 platforms.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51552 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05Fix rdar://5905347 a crash on invalid builtin, due to theChris Lattner
params not getting installed for builtins when synthesized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50676 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04add comments for the various AssignConvertType's, and split int->pointer ↵Chris Lattner
from pointer->int. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45591 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04Merge all the 'assignment' diagnostic code into one routine, decloning Chris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45589 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20implement semantic analysis for __builtin_islessequal and friends.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45239 91177308-0d34-0410-b5e6-96231b3b80d8