summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/i-c-e-cxx.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor checking of switch conditions and case values.Richard Smith2018-07-261-4/+2
| | | | | | | | | | | | | | | | | | | Check each case value in turn while parsing it, performing the conversion to the switch type within the context of the expression itself. This will become necessary in order to properly handle cleanups for temporaries created as part of the case label (in an upcoming patch). For now it's just good hygiene. This necessitates moving the checking for the switch condition itself to earlier, so that the destination type is available when checking the case labels. As a nice side-effect, we get slightly improved diagnostic quality and error recovery by separating the case expression checking from the case statement checking and from tracking whether there are discarded case labels. llvm-svn: 338056
* [Test] Make Lit tests C++11 compatible #9Charles Li2017-02-241-8/+39
| | | | | | | | [Test] Make Lit tests C++11 compatible #9 Differential Revision: https://reviews.llvm.org/D20710 llvm-svn: 296184
* C++1y: track object lifetime during constexpr evaluation, and don't allowRichard Smith2013-07-241-1/+1
| | | | | | | objects to be used once their lifetimes end. This completes the C++1y constexpr extensions. llvm-svn: 187025
* C++1y: support simple variable assignments in constexpr functions.Richard Smith2013-04-261-1/+1
| | | | llvm-svn: 180603
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-3/+3
| | | | | | | | | | | | | | | | | | 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
* Pedantic diagnostic correction: in C++, we have integral constant expressions,Richard Smith2012-01-151-1/+1
| | | | | | | | not integer constant expressions. In passing, fix the 'folding is an extension' diagnostic to not claim we're accepting the code, since that's not true in -pedantic-errors mode, and add this diagnostic to -Wgnu. llvm-svn: 148209
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-1/+1
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-2/+2
| | | | | | | | | | | | | | | | | | | | | variable is initialized by a non-constant expression, and pass in the variable being declared so that earlier-initialized fields' values can be used. Rearrange VarDecl init evaluation to make this possible, and in so doing fix a long-standing issue in our C++ constant expression handling, where we would mishandle cases like: extern const int a; const int n = a; const int a = 5; int arr[n]; Here, n is not initialized by a constant expression, so can't be used in an ICE, even though the initialization expression would be an ICE if it appeared later in the TU. This requires computing whether the initializer is an ICE eagerly, and saving that information in PCH files. llvm-svn: 146856
* Revert r142844, it broke selfhost. The problem appears to be a missingRichard Smith2011-10-241-3/+0
| | | | | | lvalue-to-rvalue conversion on the LHS operand of '->'. llvm-svn: 142872
* Constant expression evaluation: evaluate lvalues as lvalues, and rvalues asRichard Smith2011-10-241-0/+3
| | | | | | | | rvalues, as C++11 constant evaluation semantics require. DeclRefs referring to references can now use the normal initialization-caching codepath, which incidentally fixes a crash in cyclic initialization of references. llvm-svn: 142844
* In accordance with the C89, C99 and C++98 standards, ICEs can only containRichard Smith2011-10-241-4/+9
| | | | | | | floating-point literals if they are the immediate operands of casts. ImplicitCastExpr is not a cast in the language-standards sense. llvm-svn: 142832
* Extend lvalue evaluation in ExprConstant.cpp to handle CK_LValueBitCast ↵Eli Friedman2011-10-111-0/+4
| | | | | | (which is completely trivial). PR8836. llvm-svn: 141604
* PR11040: CheckICE should not allow an lvalue bitcast as part of an integer ↵Eli Friedman2011-09-291-1/+3
| | | | | | constant expression. llvm-svn: 140812
* fix rdar://9204520 - Accept int(0.85 * 10) as an initializer in a class memberChris Lattner2011-06-141-0/+13
| | | | | | as an extension. llvm-svn: 132980
* Update test for r113128.Eli Friedman2010-09-061-1/+1
| | | | llvm-svn: 113131
* If a switch condition is constant, don't warn about missing enum cases.John McCall2010-05-181-1/+1
| | | | | | | | If a switch condition is constant, warn if there's no case for it. Constant switch conditions do come up in reasonable template code. llvm-svn: 104010
* References to const int parameters with ICE default arguments are not ICEs.John McCall2010-02-241-0/+5
| | | | | | Fixes PR6373. llvm-svn: 97037
* Per discussion, remove the explicit restriction on static const data members ↵John McCall2010-02-061-0/+16
| | | | | | | | with out-of-line initializers as integer constant expressions. Fixes PR6206. llvm-svn: 95463
* 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 recursion guards to ice-checking and evaluation for declrefs, so weEli Friedman2009-12-031-0/+7
| | | | | | don't infinitely recurse for cases we can't evaluate. llvm-svn: 90480
* Eliminate some "default"s in CheckICE.Douglas Gregor2009-09-101-0/+6
| | | | llvm-svn: 81477
* static_cast, reinterpret_cast, and const_cast can all be used in C++Douglas Gregor2009-09-101-0/+4
| | | | | | | | | | integral constant expressions (for conversions to integer types, naturally). I don't *think* that const_casts will ever get to this point, but I also can't convince myself that they won't... so I've taken the safe route and allowed the ICE checking code to look at const_cast. llvm-svn: 81453
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Make const-initialized const integral variables I-C-Es in C++.Sebastian Redl2009-02-071-0/+6
llvm-svn: 64015
OpenPOWER on IntegriCloud