summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx11.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR11614: Mark defaulted special constructors as constexpr if their implicitRichard Smith2011-12-221-5/+4
| | | | | | definition would satisfy the constexpr requirements. llvm-svn: 147128
* PR11637: implement special-case constant evaluation for char arrays initializedRichard Smith2011-12-221-0/+14
| | | | | | by string literals. llvm-svn: 147120
* constexpr: diagnostic improvements for invalid lvalue-to-rvalue conversions inRichard Smith2011-12-211-17/+48
| | | | | | constant expressions. llvm-svn: 147035
* C++11 half of r147023: In C++11, additionally eagerly instantiate:Richard Smith2011-12-211-29/+17
| | | | | | | | - constexpr function template instantiations - variables of reference type - constexpr variables llvm-svn: 147031
* Evaluation support for ExprWithCleanups. We won't evaluate any expression whichRichard Smith2011-12-191-0/+6
| | | | | | actually requires non-trivial cleanups, so no cleanups need to be performed. llvm-svn: 146916
* Improve r146813 (for PR11595) to give an appropriate diagnostic.Richard Smith2011-12-191-2/+7
| | | | llvm-svn: 146915
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-37/+30
| | | | | | | | | | | | | | | | | | | | | 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
* Add a missing check before trying to evaluate a temporary. PR11595.Eli Friedman2011-12-171-0/+6
| | | | llvm-svn: 146813
* C++11 constexpr: Add note stacks containing backtraces if constant evaluationRichard Smith2011-12-161-2/+15
| | | | | | | | | | fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit argument to driver and frontend, to control the maximum number of notes so produced (default 10). Fix APValue printing to be able to pretty-print all APValue types, and move the testing for this functionality from a unittest to a -verify test now that it's visible in clang's output. llvm-svn: 146749
* Produce more detailed diagnostics when static_assert condition is not an ICE.Richard Smith2011-12-141-10/+12
| | | | llvm-svn: 146607
* Add checks and diagnostics for many of the cases which C++11 considers to notRichard Smith2011-12-131-3/+3
| | | | | | be constant expressions. llvm-svn: 146479
* Further tweaking of diagnostic text for casts performing reinterpret_castRichard Smith2011-12-121-4/+4
| | | | | | conversions in constant expressions. llvm-svn: 146406
* Clean up diagnostic wording for disallowed casts in C++11 constant expressions.Richard Smith2011-12-121-7/+7
| | | | llvm-svn: 146395
* Implement C++11 constant expression cast restrictions.Richard Smith2011-12-121-4/+29
| | | | llvm-svn: 146371
* Mechanically convert static_assert_fold to static_assert, now we implement theRichard Smith2011-12-091-186/+184
| | | | | | C++11 ICE rules. llvm-svn: 146290
* C++11 constant expressions: Don't use CheckICE in C++11; instead, determineRichard Smith2011-12-091-7/+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
* Wordsmith the -Warray-bounds diagnostic text a bitMatt Beaumont-Gay2011-11-241-2/+2
| | | | llvm-svn: 145116
* Constant expression evaluation: add support for evaluation of member pointersRichard Smith2011-11-171-4/+205
| | | | | | and base-to-derived casts, and add proper handling of temporaries. llvm-svn: 144926
* Represent an APValue based on a Decl as that Decl, rather than a DeclRefExprRichard Smith2011-11-121-0/+4
| | | | | | | | or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to static member functions and static data members are now emitted as constant expressions. llvm-svn: 144468
* Constant expression evalation: const_cast support.Richard Smith2011-11-111-0/+13
| | | | llvm-svn: 144382
* Constant expression evaluation: support for constexpr member functions. ThisRichard Smith2011-11-111-0/+671
| | | | | | | | | | | reinstates r144273; a combination of r144333's fix for NoOp rvalue-to-lvalue casts and some corresponding changes here resolve the regression which that caused. This patch also adds support for some additional forms of member function call, along with additional testing. llvm-svn: 144369
* Revert r144273. It causes clang self-host build failure.Devang Patel2011-11-101-642/+0
| | | | llvm-svn: 144296
* Constant expression evaluation: support for constexpr member functions.Richard Smith2011-11-101-0/+32
| | | | llvm-svn: 144273
* Constant expression evaluation: support for evaluation of structs and unions ofRichard Smith2011-11-101-0/+241
| | | | | | | literal types, as well as derived-to-base casts for lvalues and derived-to-virtual-base casts. llvm-svn: 144265
* Constant expression evaluation: support for default arguments.Richard Smith2011-11-091-0/+30
| | | | llvm-svn: 144156
* Fix a cluster of related issues involving value-dependence and constantRichard Smith2011-11-081-0/+15
| | | | | | | | | | | | | | expression evaluation: - When folding a non-value-dependent expression, we may try to use the initializer of a value-dependent variable. If that happens, give up. - In C++98, actually check that a const, non-volatile DeclRefExpr inside an ICE is of integral or enumeration type (a reference isn't OK!) - In C++11, DeclRefExprs for objects of const literal type initialized with value-dependent expressions are themselves value-dependent. - So are references initialized with value-dependent expressions (though this case is missing from the C++11 standard, along with many others). llvm-svn: 144056
* Constant expression evaluation: support for arrays.Richard Smith2011-11-071-0/+42
| | | | llvm-svn: 143922
* Constant expression evaluation: preserve subobject designator when flattening aRichard Smith2011-11-071-0/+18
| | | | | | core constant value down to an APValue. llvm-svn: 143909
* Allow constexpr variables' initializers to be folded in C++11 mode. ThisRichard Smith2011-11-071-5/+1
| | | | | | | | partially undoes the revert in r143491, but does not introduce any new instances of the underlying issue (which is not yet fixed) in code which does not use the 'constexpr' keyword. llvm-svn: 143905
* Clean up C++11 constant expression testing.Richard Smith2011-11-041-62/+65
| | | | llvm-svn: 143720
* Constant expression evaluation: track the manner in which an lvalue was written,Richard Smith2011-11-041-0/+26
| | | | | | | to allow us to implement the C++11 rule that a non-active union member can't be read, and use it to implement subobject access for string literals. llvm-svn: 143677
* Fix r143463 to test what it was intended to test.Richard Smith2011-11-011-2/+2
| | | | llvm-svn: 143505
* Temporarily disable lvalue-to-rvalue conversions on const pointers while anRichard Smith2011-11-011-1/+5
| | | | | | | apparent miscompile triggered by this is investigated. This is essentially a revert of r143298. llvm-svn: 143491
* Implement C++11 'constexpr calls must return constant expressions' rule, andRichard Smith2011-11-011-0/+8
| | | | | | perform the code simplifications this rule allows. llvm-svn: 143463
* Don't try to fold comparisons between the address of an object and an ↵Eli Friedman2011-10-311-0/+3
| | | | | | arbitrary integer constant. Fixes regression from r143334. llvm-svn: 143374
* Add missing lvalue-to-rvalue conversion.Eli Friedman2011-10-311-0/+3
| | | | llvm-svn: 143364
* C++11 generalized constant expression handling: evaluation support forRichard Smith2011-10-311-0/+16
| | | | | | materialized temporaries. llvm-svn: 143335
* C++11 generalized constant expressions: evaluate equality comparisons betweenRichard Smith2011-10-311-4/+12
| | | | | | arbitrary pointers, if those pointers don't point to weak objects or literals. llvm-svn: 143334
* C++11 generalized constant expressions: support pointer comparisons where theRichard Smith2011-10-311-0/+38
| | | | | | result is not unspecified. llvm-svn: 143329
* constexpr evaluation: allow lvalue-to-rvalue conversion on any literal type, notRichard Smith2011-10-291-0/+38
| | | | | | | | just integers and floating point types. Since we don't support evaluating class types or performing lvalue-to-rvalue conversions on array elements yet, this just means pointer types right now. llvm-svn: 143298
* constexpr function substitution:Richard Smith2011-10-291-3/+31
| | | | | | | | Track the function invocation where an lvalue referring to a constexpr function parameter originated from, and use it to substitute the correct argument and to determine whether such an argument's lifetime has ended. llvm-svn: 143296
* Initial support for C++11 constexpr function invocation substitution. UsingRichard Smith2011-10-281-1/+52
| | | | | | | | | | constexpr function arguments outside of their function (passing or returning them by reference) does not work correctly yet. Calling constexpr function templates does not work yet, since the bodies are not instantiated until the end of the translation unit. llvm-svn: 143234
* Reinstate r142844 (reverted in r142872) now that lvalue-to-rvalue conversionsRichard Smith2011-10-281-0/+14
| | | | | | | | | | are present in all the necessary places: In constant expression evaluation, evaluate lvalues as lvalues and rvalues as rvalues. Remove special case for caching reference initialization and fix a cyclic initialization crash in the process. llvm-svn: 143204
* Fix some cases where a CK_IntegralCast was being used to convert an lvalue to anRichard Smith2011-10-271-0/+28
rvalue. An assertion to catch this is in ImpCastExprToType will follow, but vector operations currently trip over this (due to omitting the usual arithmetic conversions). Also add an assert to catch missing lvalue-to-rvalue conversions on the LHS of ->. llvm-svn: 143155
OpenPOWER on IntegriCloud