summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr
Commit message (Collapse)AuthorAgeFilesLines
...
* constexpr: remove integral conversion overflow checking introduced in r149286.Richard Smith2012-01-311-2/+2
| | | | | | | As Eli points out, this is implementation-defined, and the way we define it makes this fine. llvm-svn: 149327
* constexpr: disallow signed integer overflow in integral conversions in constantRichard Smith2012-01-301-0/+3
| | | | | | expressions in C++11. llvm-svn: 149286
* Support decltype as a simple-type-specifier.David Blaikie2012-01-241-0/+12
| | | | | | | This makes all sorts of fun examples work with decltype. Reviewed by Richard Smith. llvm-svn: 148787
* Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler ↵Eli Friedman2012-01-201-0/+1
| | | | | | and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately. llvm-svn: 148522
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-182-2/+115
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* Make PotentiallyPotentiallyEvaluated contexts work correctly when ↵Eli Friedman2012-01-181-0/+8
| | | | | | referencing a class field from outside an instance method. llvm-svn: 148376
* 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
* Allow constant-folding of references which were formed in a manner not permittedRichard Smith2012-01-121-1/+2
| | | | | | in a constant expression, for compatibility with g++. llvm-svn: 148020
* C++11 generalized constant expressions: implement checking and diagnostics forRichard Smith2012-01-061-0/+21
| | | | | | | pointer-arithmetic-related undefined behavior and unspecified results. We continue to fold such values, but now notice they aren't constant expressions. llvm-svn: 147659
* Unrevert r147271, reverted in r147361.Richard Smith2011-12-301-2/+2
| | | | | | | | | | | | Also temporarily remove the assumption from IR gen that we can emit IR for every constant we can fold, since it isn't currently true in C++11, to fix PR11676. Original comment from r147271: constexpr: perform zero-initialization prior to / instead of performing a constructor call when appropriate. Thanks to Eli for spotting this. llvm-svn: 147384
* Revert r147271. This fixes PR11676.Rafael Espindola2011-12-301-2/+2
| | | | llvm-svn: 147362
* constexpr: support for evaluation and codegen of typeid constants.Richard Smith2011-12-271-3/+2
| | | | llvm-svn: 147290
* constexpr: perform zero-initialization prior to / instead of performing aRichard Smith2011-12-251-2/+2
| | | | | | constructor call when appropriate. Thanks to Eli for spotting this. llvm-svn: 147271
* constexpr: diagnostic improvements for invalid lvalue-to-rvalue conversions inRichard Smith2011-12-211-20/+43
| | | | | | constant expressions. llvm-svn: 147035
* Unlike in C++03, a constant-expression is not an unevaluated operand in C++11.Richard Smith2011-12-201-0/+9
| | | | | | | | | | | | | | | | | | | | | | Split out a new ExpressionEvaluationContext flag for this case, and don't treat it as unevaluated in C++11. This fixes some crash-on-invalids where we would allow references to class members in potentially-evaluated constant expressions in static member functions, and also fixes half of PR10177. The fix to PR10177 exposed a case where template instantiation failed to provide a source location for a diagnostic, so TreeTransform has been tweaked to supply source locations when transforming a type. The source location is still not very good, but MarkDeclarationsReferencedInType would need to operate on a TypeLoc to improve it further. Also fix MarkDeclarationReferenced in C++98 mode to trigger instantiation for static data members of class templates which are used in constant expressions. This fixes a link-time problem, but we still incorrectly treat the member as non-constant. The rest of the fix for that issue is blocked on PCH support for early-instantiated static data members, which will be added in a subsequent patch. llvm-svn: 146955
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-5/+5
| | | | | | | | | | | | | | | | | | | | | 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
* Reduce recursion limit on this test further to try to make the msys bot green.Richard Smith2011-12-161-3/+3
| | | | llvm-svn: 146759
* C++11 constexpr: Add note stacks containing backtraces if constant evaluationRichard Smith2011-12-161-9/+9
| | | | | | | | | | 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
* Halve the constexpr recursion depth in this test in an attempt to make theRichard Smith2011-12-141-3/+3
| | | | | | | | freebsd bots happy. In the longer term, we should have a mechanism for moving constexpr recursion off the call stack, to support the default limit of 512 suggested by the standard. llvm-svn: 146596
* Don't consider an overloaded operator& when the expression is actuallyDouglas Gregor2011-12-141-0/+28
| | | | | | going to be a pointer-to-member constant. Fixes <rdar://problem/10544564>. llvm-svn: 146587
* Disallow decltype in qualified declarator-ids.David Blaikie2011-12-131-4/+0
| | | | llvm-svn: 146480
* Add checks and diagnostics for many of the cases which C++11 considers to notRichard Smith2011-12-131-1/+354
| | | | | | be constant expressions. llvm-svn: 146479
* Support decltype in nested-name-specifiers.David Blaikie2011-12-042-2/+83
| | | | llvm-svn: 145785
* Move tests to the appropriate directory to match the spec hierarchy.David Blaikie2011-11-072-0/+0
| | | | llvm-svn: 143906
* Don't try to diagnose anything when we're passing incomplete typesDouglas Gregor2011-10-141-0/+13
| | | | | | | | through varargs. This only happens when we're in an unevaluated context, where we don't want to trigger an error anyway. Fixes PR11131 / <rdar://problem/10288375>. llvm-svn: 141986
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-1316-18/+18
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Allow calling an overloaded function set by taking the address of theDouglas Gregor2011-10-131-3/+2
| | | | | | functions, e.g., (&f)(0). Fixes <rdar://problem/9803316>. llvm-svn: 141877
* Catch placeholder types in DefaultLvalueConversionJohn McCall2011-10-111-3/+3
| | | | | | | | | | | and DefaultFunctionArrayLvalueConversion. To prevent significant regression for should-this-be-a-call fixits, and to repair some such regression from the introduction of bound member placeholders, make those placeholder checks try to build calls appropriately. Harden the build-a-call logic while we're at it. llvm-svn: 141738
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-112-0/+22
| | | | llvm-svn: 132878
* Implement the initial part of C++0x [expr.const]p2, which specifiesDouglas Gregor2011-05-241-0/+25
| | | | | | | | | | | | that the unevaluated subexpressions of &&, ||, and ? : are not considered when determining whether the expression is a constant expression. Also, turn the "used in its own initializer" warning into a runtime-behavior warning, so that it doesn't fire when a variable is used as part of an unevaluated subexpression of its own initializer. Fixes PR9999. llvm-svn: 131968
* Implement C++0x semantics for passing non-POD classes through varargs.Douglas Gregor2011-05-211-0/+17
| | | | llvm-svn: 131792
* PR9899: handle pseudo-destructors correctly in noexcept() expressions.Eli Friedman2011-05-121-0/+3
| | | | llvm-svn: 131220
* PR9882: Fix noexcept to deal with dependent new, delete, calls, andEli Friedman2011-05-111-0/+10
| | | | | | dynamic_cast correctly. llvm-svn: 131177
* Clean up our handling of template-ids that resolve down to a singleDouglas Gregor2011-03-161-3/+3
| | | | | | | | | overload, so that we actually do the resolution for full expressions and emit more consistent, useful diagnostics. Also fixes an IRGen crasher, where Sema wouldn't diagnose a resolvable bound member function template-id used in a full-expression (<rdar://problem/9108698>). llvm-svn: 127747
* Extend the noexcept expression test to test noexcept specification functions.Sebastian Redl2011-03-151-0/+4
| | | | llvm-svn: 127693
* Add -fcxx-exceptions to all tests that use C++ exceptions.Anders Carlsson2011-02-282-4/+4
| | | | llvm-svn: 126599
* Implement the C++0x deduced 'auto' feature.Richard Smith2011-02-201-0/+23
| | | | | | This fixes PR 8738, 9060 and 9132. llvm-svn: 126069
* Pass -fexceptions to all tests that use try/catch/throw.Anders Carlsson2011-02-192-4/+4
| | | | llvm-svn: 126037
* Implement C++0x [expr.static.cast]p9, which permits explicitly castingDouglas Gregor2011-02-181-0/+29
| | | | | | | | | | a scoped enumeration type to an integral or floating type, properly. There was an over-eager assertion, and it was missing the floating-point case. Fixes PR9107/<rdar://problem/8937402>. llvm-svn: 125825
* A few more tweaks to the blocks AST representation: John McCall2011-02-071-4/+4
| | | | | | | | | | | | | | | | | - BlockDeclRefExprs always store VarDecls - BDREs no longer store copy expressions - BlockDecls now store a list of captured variables, information about how they're captured, and a copy expression if necessary With that in hand, change IR generation to use the captures data in blocks instead of walking the block independently. Additionally, optimize block layout by emitting fields in descending alignment order, with a heuristic for filling in words when alignment of the end of the block header is insufficient for the most aligned field. llvm-svn: 125005
* When calling a bound pointer to member function, check theDouglas Gregor2011-02-041-0/+61
| | | | | | | cv-qualifiers on the object against the cv-qualifiers on the member function. Fixes PR8315. llvm-svn: 124865
* Implement access checking for the "delete" operator. Fixes PR9050,Douglas Gregor2011-02-011-5/+17
| | | | | | from Alex Miller! llvm-svn: 124663
* Fix a horrible bug in our handling of C-style casting, where a C-styleDouglas Gregor2011-01-271-0/+23
| | | | | | | | | | | derived-to-base cast that also casts away constness (one of the cases for static_cast followed by const_cast) would be treated as a bit-cast rather than a derived-to-base class, causing miscompiles and heartburn. Fixes <rdar://problem/8913298>. llvm-svn: 124340
* Handle C-style casts to rvalue reference types that cast away constness.Douglas Gregor2011-01-261-0/+11
| | | | llvm-svn: 124319
* Reference qualifiers for *this: implement C++0x [expr.mptr.oper]p6,Douglas Gregor2011-01-261-0/+34
| | | | | | | the restrictions on .* and ->* for ref-qualified pointer-to-member functions. llvm-svn: 124294
* Update const_cast semantics for rvalue references. Add tests forDouglas Gregor2011-01-222-0/+33
| | | | | | reinterpret_cast and const_cast using rvalue references. llvm-svn: 124007
* Teach static_cast and dynamic_cast about rvalue references.Douglas Gregor2011-01-222-0/+38
| | | | llvm-svn: 124006
* Implement substitution of a function parameter pack for its set ofDouglas Gregor2011-01-071-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | instantiated function parameters, enabling instantiation of arbitrary pack expansions involving function parameter packs. At this point, we can now correctly compile a simple, variadic print() example: #include <iostream> #include <string> void print() {} template<typename Head, typename ...Tail> void print(const Head &head, const Tail &...tail) { std::cout << head; print(tail...); } int main() { std::string hello = "Hello"; print(hello, ", world!", " ", 2011, '\n'); } llvm-svn: 123000
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-0/+26
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Properly diagnose invalid casts to function references. Patch byDouglas Gregor2010-11-081-4/+2
| | | | | | Faisal Vali, tweaked by me. Fixes PR8230. llvm-svn: 118400
OpenPOWER on IntegriCloud