summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/i-c-e.c
Commit message (Collapse)AuthorAgeFilesLines
* When evaluating a __builtin_constant_p conditional, always enterRichard Smith2019-09-101-0/+3
| | | | | | | | | | | constant-folding mode regardless of the original evaluation mode. In order for this to be correct, we need to track whether we're checking for a potential constant expression or checking for undefined behavior separately from the evaluation mode enum, since we don't want to clobber those states when entering constant-folding mode. llvm-svn: 371557
* Move a bunch of tests to directly use the CC1 layer. This at least savesChandler Carruth2014-01-151-1/+1
| | | | | | | | | | | a subprocess invocation which is pretty significant on Windows. It also likely saves a bunch of thrashing the host machine needlessly. Finally it makes the tests much more predictable and less dependent on the host. For example 'header_lookup1.c' was passing '-fno-ms-extensions' just to thwart the host detection adding it into the compilation. By runnig CC1 directly we don't have to deal with such oddities. llvm-svn: 199308
* PR14729: Fix typo in CheckICE for BinaryConditionalOperators.Richard Smith2012-12-281-0/+2
| | | | llvm-svn: 171191
* Implement GCC's -Wint-to-pointer-cast.David Blaikie2012-10-161-1/+1
| | | | | | | | | | | | This implementation doesn't warn on anything that GCC doesn't warn on with the exception of templates specializations (GCC doesn't warn, Clang does). The specific skipped cases (boolean, constant expressions, enums) are open for debate/adjustment if anyone wants to demonstrate that GCC is being overly conservative here. The only really obvious false positive I found was in the Clang regression suite's MPI test - apparently MPI uses specific flag values in pointer constants. (eg: #define FOO (void*)~0) llvm-svn: 166039
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-2/+2
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Make clang's AST model sizeof and typeof with potentially-evaluated operands ↵Eli Friedman2012-01-211-10/+7
| | | | | | correctly, similar to what we already do with typeid. llvm-svn: 148610
* C++11 constant expressions: Don't use CheckICE in C++11; instead, determineRichard Smith2011-12-091-1/+1
| | | | | | | | | | | | whether an expression is a (core) constant expression as a side-effect of evaluation. This takes us from accepting far too few expressions as ICEs to accepting slightly too many -- fixes for the remaining cases are coming next. The diagnostics produced when an expression is found to be non-constant are currently quite poor (with generic wording but reasonable source locations), and will be improved in subsequent commits. llvm-svn: 146289
* In accordance with the C89, C99 and C++98 standards, ICEs can only containRichard Smith2011-10-241-0/+3
| | | | | | | floating-point literals if they are the immediate operands of casts. ImplicitCastExpr is not a cast in the language-standards sense. llvm-svn: 142832
* Add fixit notes for -Wconstant-logical-operand.Matt Beaumont-Gay2011-08-151-1/+2
| | | | llvm-svn: 137620
* 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
* Don't crash during constant-evaluation of 1/(1/0). PR9262.John McCall2011-02-261-0/+2
| | | | llvm-svn: 126541
* Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the ↵Ted Kremenek2011-02-231-1/+3
| | | | | | | | | | related code is reachable. This suppresses some diagnostics that occur in unreachable code (e.g., -Warray-bound). We only pay the cost of doing the reachability analysis when we issue one of these diagnostics. llvm-svn: 126290
* This really seems like a boring set of fixes to our tests to make them moreChandler Carruth2010-11-161-1/+1
| | | | | | | independent of the underlying system. Let me know if any of these are too aggressive. llvm-svn: 119345
* Fixed __builtin_constant_p return type.Abramo Bagnara2010-10-091-0/+1
| | | | llvm-svn: 116145
* Revert r114316, -Wunused-value enabled by default was intended.Argyrios Kyrtzidis2010-09-191-3/+5
| | | | llvm-svn: 114318
* Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.Argyrios Kyrtzidis2010-09-191-5/+3
| | | | llvm-svn: 114316
* Add a warning to catch a bug recently caught by code review, like this:Chris Lattner2010-07-131-1/+2
| | | | | | | | | | | t2.c:2:12: warning: use of logical && with constant operand; switch to bitwise & or remove constant [-Wlogical-bitwise-confusion] return x && 4; ^ ~ wording improvement suggestions are welcome. llvm-svn: 108260
* Fix rdar://8139785 "implement warning on dead expression in comma operator"Argyrios Kyrtzidis2010-06-301-3/+4
| | | | | | | | | | 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
* implement PR6004, warning about divide and remainder by zero.Chris Lattner2010-01-121-2/+3
| | | | llvm-svn: 93256
* Update tests to use %clang instead of 'clang', and forcibly disable use of 'Daniel Dunbar2009-12-151-1/+1
| | | | | | | clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to garbage). llvm-svn: 91460
* Use clang to run tests which include headers from the system.Daniel Dunbar2009-11-171-1/+1
| | | | llvm-svn: 89085
* Simplify the scheme used for keywords, and change the classification Eli Friedman2009-04-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change isNullPointerConstant to be strict; hopefully this won't cause Eli Friedman2009-04-251-1/+1
| | | | | | any issues now that we have our own tgmath.h. llvm-svn: 70090
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Some additional ICE tests.Eli Friedman2009-02-271-0/+18
| | | | llvm-svn: 65614
* Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p Chris Lattner2008-12-121-0/+13
| | | | | | | processing: it allows arbitrary foldable constants as the operand of ?: when builtin_constant_p is the condition. llvm-svn: 60954
* merge these testcases into one file.Chris Lattner2008-12-121-0/+35
llvm-svn: 60936
OpenPOWER on IntegriCloud