summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/integer-overflow.c
Commit message (Collapse)AuthorAgeFilesLines
* [Diagnostics] Check for integer overflow in array size expressions David Bolvansky2018-10-181-0/+3
| | | | | | | | | | | | | | Summary: Fixes PR27439 Reviewers: rsmith, Rakete1111 Reviewed By: rsmith Subscribers: Rakete1111, cfe-commits Differential Revision: https://reviews.llvm.org/D52750 llvm-svn: 344759
* [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.Volodymyr Sapsai2018-03-271-0/+15
| | | | | | | | | | | | | | rdar://problem/35539384 Reviewers: ahatanak, nicholas, rsmith, jkorous-apple Reviewed By: jkorous-apple Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D42938 llvm-svn: 328671
* Revert r301742, which caused us to try to evaluate all full-expressions.Richard Smith2017-06-261-7/+1
| | | | | | | | | | | | | | Also add testcases for a bunch of expression forms that cause our evaluator to crash. See PR33140 and PR32864 for crashes that this was causing. This reverts r305287, which reverted r305239, which reverted r301742. The previous revert claimed that buildbots were broken, but did not add any testcases and the buildbots have lost all memory of what was wrong here. Changes to test/OpenMP are not reverted; another change has triggered those tests to change their output in the same way that r301742 did. llvm-svn: 306346
* Revert "Revert r301742 which made ExprConstant checking apply to all ↵Diana Picus2017-06-131-1/+7
| | | | | | | | | full-exprs." This reverts commit r305239 because it broke the buildbots (the diag-flags.cpp test is failing). llvm-svn: 305287
* Revert r301742 which made ExprConstant checking apply to all full-exprs.Nick Lewycky2017-06-121-7/+1
| | | | | | This patch also exposed pre-existing bugs in clang, see PR32864 and PR33140#c3 . llvm-svn: 305239
* Revert r303316, a change to ExprConstant to evaluate function arguments.Nick Lewycky2017-06-121-8/+0
| | | | | | The patch was itself correct but it uncovered other bugs which are going to be difficult to fix, per PR33140. llvm-svn: 305233
* The constant expression evaluator should examine function arguments for ↵Nick Lewycky2017-05-171-0/+8
| | | | | | non-constexpr function calls unless the EvalInfo says to stop. llvm-svn: 303317
* Revert r301785 (and r301787) because they caused PR32864.Nick Lewycky2017-05-021-4/+4
| | | | | | The fix is that ExprEvaluatorBase::VisitInitListExpr should handle transparent exprs instead of exprs with one element. Fixing that uncovers one testcase failure because the AST for "constexpr _Complex float test2 = {1};" is wrong (the _Complex prvalue should not be const-qualified), and a number of test failures in test/OpenMP where the captured stmt contains an InitListExpr that is in syntactic form. llvm-svn: 301891
* Fix test that was incorrected merged between patches.Nick Lewycky2017-05-011-1/+1
| | | | llvm-svn: 301787
* Handle expressions with non-literal types like ignored expressions if we are ↵Nick Lewycky2017-05-011-4/+4
| | | | | | | | supposed to continue evaluating them. Also fix a crash casting a derived nullptr to a virtual base. llvm-svn: 301785
* Remove Sema::CheckForIntOverflow, and instead check all full-expressions.Nick Lewycky2017-04-291-1/+7
| | | | | | | | CheckForIntOverflow used to implement a whitelist of top-level expressions to send to the constant expression evaluator, which handled many more expressions than the CheckForIntOverflow whitelist did. llvm-svn: 301742
* In the expression evaluator, visit the index of an ArraySubscriptExpr even ↵Nick Lewycky2017-04-271-0/+4
| | | | | | if we can't evaluate the base, if the evaluation mode tells us to continue evaluation. llvm-svn: 301522
* In the expression evaluator, descend into both the true and false ↵Nick Lewycky2017-04-271-0/+3
| | | | | | expressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we should continue evaluating. llvm-svn: 301520
* Adjust tests to have consistent integer sizes.Richard Trieu2016-04-111-2/+7
| | | | | | | Add a triple to the run lines so that integers will the same sizes across runs. Also add a compile time check to ensure the assumptions about sizes are met. llvm-svn: 265991
* [Sema] Issue a warning for integer overflow in nested struct initializerAkira Hatanaka2016-02-101-0/+20
| | | | | | | | | | | | | | | | | | | | | | | r257357 fixed clang to warn on integer overflow in struct initializers. However, it didn't warn when a struct had a nested initializer. This commit makes changes in Sema::CheckForIntOverflow to handle nested initializers. For example: struct s { struct t { unsigned x; } t; } s = { { .x = 4 * 1024 * 1024 * 1024 } }; rdar://problem/23526454 llvm-svn: 260360
* [Sema] Issue a warning for integer overflow in struct initializerAkira Hatanaka2016-01-111-0/+8
| | | | | | | | | | | | | | | | Clang wasn't issuing a warning when compiling the following code: struct s { unsigned x; } s = { .x = 4 * 1024 * 1024 * 1024 }; rdar://problem/23399683 Differential Revision: http://reviews.llvm.org/D15097 llvm-svn: 257357
* Explicitly permit undefined behavior in constant initializers for globalRichard Smith2015-12-081-1/+0
| | | | | | | | variables in C, in the cases where we can constant-fold it to a value regardless (such as floating-point division by zero and signed integer overflow). Strictly enforcing this rule breaks too much code. llvm-svn: 254992
* PR17381: Treat undefined behavior during expression evaluation as an unmodeledRichard Smith2015-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | | side-effect, so that we don't allow speculative evaluation of such expressions during code generation. This caused a diagnostic quality regression, so fix constant expression diagnostics to prefer either the first "can't be constant folded" diagnostic or the first "not a constant expression" diagnostic depending on the kind of evaluation we're doing. This was always the intent, but didn't quite work correctly before. This results in certain initializers that used to be constant initializers to no longer be; in particular, things like: float f = 1e100; are no longer accepted in C. This seems appropriate, as such constructs would lead to code being executed if sanitizers are enabled. llvm-svn: 254574
* Catch more cases when diagnosing integer-constant-expression overflows.Josh Magee2015-02-041-0/+147
When visiting AssignmentOps, keep evaluating after a failure (when possible) in order to identify overflow in subexpressions. Differential Revision: http://reviews.llvm.org/D1238 llvm-svn: 228202
OpenPOWER on IntegriCloud