summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/const-eval.c
Commit message (Collapse)AuthorAgeFilesLines
* PR16074, implement warnings to catch pointer to boolean true and pointer toRichard Trieu2014-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | null comparison when the pointer is known to be non-null. This catches the array to pointer decay, function to pointer decay and address of variables. This does not catch address of function since this has been previously used to silence a warning. Pointer to bool conversion is under -Wbool-conversion. Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group of -Wtautological-compare. void foo() { int arr[5]; int x; // warn on these conditionals if (foo); if (arr); if (&x); if (foo == null); if (arr == null); if (&x == null); if (&foo); // no warning } llvm-svn: 202216
* Don't treat overflow in floating-point conversions as a hard error in ↵Eli Friedman2012-07-171-0/+3
| | | | | | constant evaluation. <rdar://problem/11874571>. llvm-svn: 160394
* Per Richard's comments on r154794, add the checks necessary to handle ↵Eli Friedman2012-04-161-0/+6
| | | | | | constant-folding relational comparisons safely in case the user is using -fwrapv or equivalent. llvm-svn: 154849
* Make constant evaluation for pointer comparisons work correctly for some ↵Eli Friedman2012-04-161-0/+4
| | | | | | uncommon cases. <rdar://problem/10962435>. llvm-svn: 154794
* Add test for a construct we currently reject, constant-evaluating a load ↵Eli Friedman2012-04-111-0/+4
| | | | | | from a constant string. Given that gcc doesn't accept this, we should continue to not accept it, even though it was accidentally supported by clang for a brief period. llvm-svn: 154564
* Fix a crash in the diangostic code in EvalConstant. PR12043.Eli Friedman2012-02-211-0/+5
| | | | llvm-svn: 151100
* constexpr: evaluate (bool)&x as true when x is a local variable or a temporary.Richard Smith2012-01-261-1/+1
| | | | llvm-svn: 149045
* When folding the size of a global scope VLA to a constant, require the arrayRichard Smith2011-12-071-2/+2
| | | | | | | bound to not have side effects(!). Add constant-folding support for expressions of void type, to ensure that we can still fold ((void)0, 1) as an array bound. llvm-svn: 146000
* PR11391: Don't try to evaluate the LHS of a _Complex assignment as an rvalue.Richard Smith2011-11-161-0/+4
| | | | llvm-svn: 144799
* Fix PR11385: A pointer constant expression which has been cast via an integer isRichard Smith2011-11-161-1/+4
| | | | | | | not safely derived. Don't allow lvalue-to-rvalue conversions on the result of dereferencing such a pointer. llvm-svn: 144783
* Add missing casts to AST.Eli Friedman2011-11-121-0/+3
| | | | llvm-svn: 144455
* Constant expression evaluation: although we don't know whether a literal willRichard Smith2011-11-041-0/+3
| | | | | | | be at the same address as another object, we do know it won't alias a null pointer. llvm-svn: 143674
* When constant-folding, don't look at the initializer of a global const variableRichard Smith2011-11-011-0/+4
| | | | | | if it's marked as weak: that definition may not end up being used. llvm-svn: 143496
* Refactoring and test for r143360. Support for array rvalue to pointer decay isRichard Smith2011-10-311-0/+3
| | | | | | needed for C++11, and will follow later. llvm-svn: 143363
* Fix assert on constant expression evaluation of floating point increment.Richard Smith2011-10-301-0/+1
| | | | llvm-svn: 143320
* Don't crash if a GCC binary conditional is used in a constant expression on anRichard Smith2011-10-291-0/+3
| | | | | | integer-cast pointer value. llvm-svn: 143299
* Fix assertion in constant expression evaluation. The LHS of a floating-pointRichard Smith2011-10-281-0/+2
| | | | | | binary operator isn't an rvalue if it's an assignment operator. llvm-svn: 143250
* when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be ↵Chris Lattner2011-06-141-1/+1
| | | | | | | | | | folded to a constant as constant size arrays. This has slightly different semantics in some insane cases, but allows us to accept some constructs that GCC does. Continue to be pedantic in -std=c99 and other modes. This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code llvm-svn: 132983
* Fix tests to account for new warning "expected ';' at end of declaration ↵Carl Norum2011-03-071-1/+1
| | | | | | list". Sorry, folks! llvm-svn: 127188
* Properly do a float -> _Complex double conversion, fixes rdar://8875946.Argyrios Kyrtzidis2011-01-181-0/+6
| | | | llvm-svn: 123759
* fix PR7885, rejecting invalid uses of __builtin_constant_p.Chris Lattner2010-10-121-1/+1
| | | | llvm-svn: 116317
* PR7884: Fix the implementations of __real__ and __imag__ on real floats.Eli Friedman2010-08-141-2/+6
| | | | llvm-svn: 111080
* Make the "unused result" warning a warning about run-time behavior, soDouglas Gregor2010-07-151-1/+1
| | | | | | that we don't warn when there isn't going to be any computation anyway. llvm-svn: 108442
* Fix rdar://8139785 "implement warning on dead expression in comma operator"Argyrios Kyrtzidis2010-06-301-1/+1
| | | | | | | | | | As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g: x || test_logical_foo1(); emitted a bogus "expression result unused" for 'x'. llvm-svn: 107274
* Fix for PR6274: teach constant folding to evaluate __builtin_expect.Eli Friedman2010-02-131-0/+1
| | | | llvm-svn: 96054
* 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
* Add constant evaluation for comma operator with floating-point operand. FixesEli Friedman2009-11-161-0/+2
| | | | | | PR5449. llvm-svn: 88885
* Make ASTContext::getIntWidth return 1 for all boolean type variations, not ↵Sebastian Redl2009-11-051-0/+5
| | | | | | just for the unqualified, unaliased bool. llvm-svn: 86174
* PR4351: Add constant evaluation for constructs like "foo == NULL", where Eli Friedman2009-06-141-0/+2
| | | | | | foo has a constant address. llvm-svn: 73321
* PR4326: Handle constant evaluation for void* pointer subtraction Eli Friedman2009-06-041-0/+1
| | | | | | correctly. llvm-svn: 72886
* PR4097: add logic to Evaluate to handle pointer equality comparisons.Eli Friedman2009-04-281-0/+2
| | | | llvm-svn: 70317
* Add handling for complex->int, int->complex float, and float->complex Eli Friedman2009-04-221-0/+2
| | | | | | | int. Note that constant int->complex float and float->complex int casts were being miscompiled. llvm-svn: 69821
* Fix PR4027 + rdar://6808859, we were rejecting implicit casts ofChris Lattner2009-04-211-0/+6
| | | | | | aggregates even though we already accept explicit ones. Easy fix. llvm-svn: 69661
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Minor enhancements to Evaluate.Eli Friedman2009-03-231-0/+5
| | | | llvm-svn: 67503
* Fix invalid VLAs/VMs in Sema::ActOnVariableDeclarator, so that the variable ↵Anders Carlsson2009-02-281-0/+3
| | | | | | | | | | | will have the right type by the time the initializer is checked. This ensures that code like int a[(int)(1.0 / 1.0) = { 1 } will work. Eli, please review. llvm-svn: 65725
* Fix obvious shortcoming in the implementations of Evaluate for Eli Friedman2009-02-281-0/+5
| | | | | | integer __real__ and __imag__. Not sure how I missed this. llvm-svn: 65677
* Evaluation of unary deref could call integer evaluator on non-integralDaniel Dunbar2009-02-211-0/+2
| | | | | | | expr; hilarity ensued. - PR3640. llvm-svn: 65234
* Add support for * (unary dereference) operator to ExprConstant.Eli Friedman2009-02-201-0/+2
| | | | llvm-svn: 65105
* Emit the correct diagnostics when we constant fold an array size to a ↵Anders Carlsson2009-02-191-0/+4
| | | | | | negative value. llvm-svn: 65023
* Make sure to check the value of the constant expression, as suggested by Daniel.Anders Carlsson2009-02-191-1/+1
| | | | llvm-svn: 65021
* Handle the GNU void* and function pointer arithmetic extensions for constant ↵Anders Carlsson2009-02-191-0/+2
| | | | | | expressions as well. llvm-svn: 65013
* isICE was evaluating ?: incorrectly with missing-gcc-LHS extension.Daniel Dunbar2009-02-181-0/+3
| | | | | | | Add assert to isICE that, on success, result must be the same as EvaluateAsInt()... this enforces a minimum level of sanity. llvm-svn: 64865
* Fix invalid evaluation of _Complex float (real & imaginary parts hadDaniel Dunbar2009-01-241-0/+3
| | | | | | | mismatched semantics). - Enforce this in APValue. llvm-svn: 62924
* The address of a variable is only constant if the variable has global storage.Anders Carlsson2008-11-241-0/+6
| | | | llvm-svn: 59939
* Fix bug in the constant evaluator. Fixes PR3115.Anders Carlsson2008-11-241-0/+3
| | | | llvm-svn: 59938
* Fix for crash issues with comma operators with a void first operand, and Eli Friedman2008-11-131-0/+6
| | | | | | | | | | some more bullet-proofing/enhancements for tryEvaluate. This shouldn't cause any behavior changes except for handling cases where we were crashing before and being able to evaluate a few more cases in tryEvaluate. This should settle the minor mess surrounding r59196. llvm-svn: 59224
* Backout of r59196, plus a new ICE test. Sorry if this is a Eli Friedman2008-11-131-2/+0
| | | | | | | | | | | | | | | | | | little rude; I figure it's cleaner to just back this out now so it doesn't get forgotten or mixed up with other checkins. The modification to isICE is simply wrong; I've added a test that the change to isICE breaks. I'm pretty sure the modification to tryEvaluate is also wrong. At the very least, there's some serious miscommunication going on here, as this is going in exactly the opposite direction of r59105. My understanding is that tryEvaluate is not supposed to care about side effects. That said, a lot of the clients to tryEvaluate are expecting it to enforce a no-side-effects policy, so we probably need another method that provides that guarantee. llvm-svn: 59212
* Fix bug in constant evaluation exposed by 176.gcc.Daniel Dunbar2008-11-131-0/+2
| | | | | | | | | | | | - Evaluation of , operator used bogus assumption that LHS could be evaluated as an integral expression even though its type is unspecified. This change is making isICE very permissive of the LHS in non-evaluated contexts because it is not clear what predicate we would use to reject code here. The standard didn't offer me any guidance; opinions? llvm-svn: 59196
* Some additions to tryEvaluate I've had sitting around for a while.Eli Friedman2008-11-121-0/+13
This pushes it a lot closer to being able to deal with most of the stuff CodeGen's constant expression evaluator knows how to deal with. This also fixes PR3003. The test could possibly use some improvement, but this'll work for now. Test 6 is inspired by PR3003; the other tests are mostly just designed to exercise the new code. The reason for the funny structure of the tests is that type fixing for arrays inside of structs is the only place in Sema that calls tryEvaluate, at least for the moment. llvm-svn: 59125
OpenPOWER on IntegriCloud