summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/enable_if.c
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] Deduplicate some availability checking logicErik Pilkington2019-03-201-11/+11
| | | | | | | | | | | | | | | Before this commit, we emit unavailable errors for calls to functions during overload resolution, and for references to all other declarations in DiagnoseUseOfDecl. The early checks during overload resolution aren't as good as the DiagnoseAvailabilityOfDecl based checks, as they error on the code from PR40991. This commit fixes this by removing the early checking. llvm.org/PR40991 rdar://48564179 Differential revision: https://reviews.llvm.org/D59394 llvm-svn: 356599
* Update the tests to match the typo fix done in r292015Sylvestre Ledru2017-01-141-2/+2
| | | | llvm-svn: 292016
* [Sema] Fix a crash on variadic enable_if functions.George Burgess IV2016-08-121-0/+21
| | | | | | | | | | | | | Currently, when trying to evaluate an enable_if condition, we try to evaluate all arguments a user passes to a function. Given that we can't use variadic arguments from said condition anyway, not converting them is a reasonable thing to do. So, this patch makes us ignore any varargs when attempting to check an enable_if condition. We'd crash because, in order to convert an argument, we need its ParmVarDecl. Variadic arguments don't have ParmVarDecls. llvm-svn: 278471
* Add the Pure attribute to C99 builtin functions from ctype.h. This is a ↵Aaron Ballman2016-05-041-2/+2
| | | | | | | | corrected version of r266199 with test case fixes. Patch by Taewook Oh. llvm-svn: 268553
* Reverting r266199; it causes build bot failures.Aaron Ballman2016-04-131-2/+2
| | | | | | | http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/3255 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3517 llvm-svn: 266201
* Add functions declared in ctype.h to builtin function database. All ↵Aaron Ballman2016-04-131-2/+2
| | | | | | | | functions are annotated with nothrow and pure attribute, which enables better optimization. Patch by Taewook Oh. llvm-svn: 266199
* [Sema] Fix PR27122: ICE with enable_if+ill-formed call.George Burgess IV2016-03-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | In some cases, when we encounter a direct function call with an incorrect number of arguments, we'll emit a diagnostic, and pretend that the call to the function was valid. For example, in C: int foo(); int a = foo(1); Prior to this patch, we'd get an ICE if foo had an enable_if attribute, because CheckEnableIf assumes that the number of arguments it gets passed is valid for the function it's passed. Now, we check that the number of args looks valid prior to checking enable_if conditions. This fix was not done inside of CheckEnableIf because the problem presently can only occur in one caller of CheckEnableIf (ActOnCallExpr). Additionally, checking inside of CheckEnableIf would make us emit multiple diagnostics for the same error (one "enable_if failed", one "you gave this function the wrong number of arguments"), which seems worse than just complaining about the latter. llvm-svn: 264975
* Add tests for `&enable_if_function` diagnostics.George Burgess IV2015-12-031-0/+6
| | | | | | | | The introduction of pass_object_size fixed a few bugs related to taking the address of a function with enable_if attributes. This patch adds tests for the cases that were fixed. llvm-svn: 254646
* [Sema] Fix address-of + enable_if overloading logicGeorge Burgess IV2015-10-161-9/+11
| | | | | | | | | | | | | | | | | Previously, our logic when taking the address of an overloaded function would not consider enable_if attributes, so long as all of the enable_if conditions on a given candidate were true. So, two functions with identical signatures (one with enable_if attributes, the other without), would be considered equally good overloads. If we were calling the function instead of taking its address, then the function with enable_if attributes would be preferred. This patch makes us prefer the candidate with enable_if regardless of if we're calling or taking the address of an overloaded function. Differential Revision: http://reviews.llvm.org/D13795 llvm-svn: 250486
* [Sema] Make `&function_with_enable_if_attrs` an errorGeorge Burgess IV2015-10-121-0/+25
| | | | | | | | | | | | | | | | | | This fixes a bug where one can take the address of a conditionally enabled function to drop its enable_if guards. For example: int foo(int a) __attribute__((enable_if(a > 0, ""))); int (*p)(int) = &foo; int result = p(-1); // compilation succeeds; calls foo(-1) Overloading logic has been updated to reflect this change, as well. Functions with enable_if attributes that are always true are still allowed to have their address taken. Differential Revision: http://reviews.llvm.org/D13607 llvm-svn: 250090
* Support alternate attribute spelling __enable_if__Ulrich Weigand2015-07-131-0/+15
| | | | | | | | | | | | | | | | | | | | Attribute names usually support an alternate spelling that uses double underscores before and after the attribute name, like e.g. attribute ((__aligned__)) for attribute ((aligned)). This is necessary to allow use of attributes in system headers without polluting the name space. However, for attribute ((enable_if)) that alternate spelling does not work correctly. This is because of code in Parser::ParseGNUAttributeArgs (ParseDecl.cpp) that specifically checks for the "enable_if" spelling without allowing the alternate spelling. Similar code in ParseDecl.cpp uses the normalizeAttrName helper to allow both spellings. This patch adds use of that helper for the "enable_if" check as well, which fixes attribute ((__enable_if__)). Differential Revision: http://reviews.llvm.org/D11142 llvm-svn: 242029
* Account for calling convention specifiers in function definitions in IR test ↵David Blaikie2015-06-291-1/+1
| | | | | | | | | | | | | cases Several tests wouldn't pass when executed on an armv7a_pc_linux triple due to the non-default arm_aapcs calling convention produced on the function definitions in the IR output. Account for this with the application of a little regex. Patch by Ying Yi. llvm-svn: 240971
* Neither attribute overloadable nor enable_if are supported by GCC. Disable theNick Lewycky2014-01-211-2/+2
| | | | | | GCC warning about attributes on function definitions for both of them. llvm-svn: 199710
* Add a new attribute 'enable_if' which can be used to control overload ↵Nick Lewycky2014-01-111-0/+97
resolution based on the values of the function arguments at the call site. llvm-svn: 198996
OpenPOWER on IntegriCloud