summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr
Commit message (Collapse)AuthorAgeFilesLines
...
* Specialize the diagnostic complaining about conflicting types ofDouglas Gregor2012-02-151-2/+2
| | | | | | | return statements within a lambda; this diagnostic previously referred to blocks. llvm-svn: 150584
* Implement DR1454. This allows all intermediate results in constant expressionsRichard Smith2012-02-151-14/+12
| | | | | | | | | | | | to be core constant expressions (including pointers and references to temporaries), and makes constexpr calculations Turing-complete. A Turing machine simulator is included as a testcase. This opens up the possibilty of removing CCValue entirely, and removing some copies from the constant evaluator in the process, but that cleanup is not part of this change. llvm-svn: 150557
* Implement C++ core issue 974, which permits default arguments forDouglas Gregor2012-02-142-2/+53
| | | | | | | | lambda expressions. Because these issue was pulled back from Ready status at the Kona meeting, we still emit an ExtWarn when using default arguments for lambda expressions. llvm-svn: 150519
* Check the return type of lambda expressions.Douglas Gregor2012-02-142-0/+16
| | | | llvm-svn: 150503
* Implement support for lambda capture pack expansions, e.g.,Douglas Gregor2012-02-141-0/+58
| | | | | | [&values...] { print(values...); } llvm-svn: 150497
* Simple test ensuring that we perform direct initialization when ↵Douglas Gregor2012-02-141-0/+9
| | | | | | copy-capturing in lambdas llvm-svn: 150442
* Link together the call operator produced from transforming a lambdaDouglas Gregor2012-02-141-0/+71
| | | | | | | | expression with the original call operator, so that we don't try to separately instantiate the call operator. Test and tweak a few more bits for template instantiation of lambda expressions. llvm-svn: 150440
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-0/+45
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-7/+12
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* Within the body of a lambda expression, decltype((x)) for anDouglas Gregor2012-02-122-2/+43
| | | | | | | | | | | | | | | | id-expression 'x' will compute the type based on the assumption that 'x' will be captured, even if it isn't captured, per C++11 [expr.prim.lambda]p18. There are two related refactors that go into implementing this: 1) Split out the check that determines whether we should capture a particular variable reference, along with the computation of the type of the field, from the actual act of capturing the variable. 2) Always compute the result of decltype() within Sema, rather than AST, because the decltype() computation is now context-sensitive. llvm-svn: 150347
* Lambdas have a deleted default constructor and a deleted copyDouglas Gregor2012-02-124-0/+46
| | | | | | assignment operator, per C++ [expr.prim.lambda]p19. Make it so. llvm-svn: 150345
* Make sure Sema creates a field for 'this' captures. (Doug, please ↵Eli Friedman2012-02-111-0/+8
| | | | | | double-check that this is correct.) llvm-svn: 150292
* Add simple semantic test for C++11 [expr.prim.lambda]p16, which covers ↵Douglas Gregor2012-02-101-0/+16
| | | | | | recursive capture. This is far more interesting for IRgen. llvm-svn: 150283
* Implement C++11 [expr.lambda.prim]p13, which prohibits lambdas inDouglas Gregor2012-02-101-0/+10
| | | | | | default arguments if in fact those lambdas capture any entity. llvm-svn: 150282
* Allow implicit capture of 'this' in a lambda even when the captureDouglas Gregor2012-02-101-3/+7
| | | | | | | | | | | | default is '=', and reword the warning about explicitly capturing 'this' in such lambdas to indicate that only explicit capture is banned. Introduce Fix-Its for this and other "save the programmer from themself" rules regarding what can be explicitly captured and what must be implicitly captured. llvm-svn: 150256
* Add test from [expr.prim.lambda]p12, which deals with odr-use andDouglas Gregor2012-02-101-0/+30
| | | | | | | | nested captures. We currently don't get odr-use correct in array bounds, so that bit is commented out while we sort out what we need to do. llvm-svn: 150255
* Don't introduce a lambda's operator() into the class until after weDouglas Gregor2012-02-101-0/+9
| | | | | | | | have finished parsing the body, so that name lookup will never find anything within the closure type. Then, add this operator() and the conversion function (if available) before completing the class. llvm-svn: 150252
* Add a lambda example from the working draft.Douglas Gregor2012-02-101-0/+9
| | | | llvm-svn: 150239
* Add various tests for captures and the reaching scope of the lambdaDouglas Gregor2012-02-103-0/+79
| | | | | | | expression. Implement C++11 [expr.prim.lambda]p12's requirement that capturing a variable will odr-use it. llvm-svn: 150237
* Implement the conversion to a function pointer for lambda expressions,Douglas Gregor2012-02-102-3/+25
| | | | | | per C++ [expr.prim.lambda]p6. llvm-svn: 150236
* Update to new resolution for DR1458. When taking the address of an object ofRichard Smith2012-02-101-3/+4
| | | | | | | incomplete class type which has an overloaded operator&, it's now just unspecified whether the overloaded operator or the builtin is used. llvm-svn: 150234
* Don't allow deduction of a lambda result type from an initializerDouglas Gregor2012-02-091-0/+1
| | | | | | list; it is not an expression. llvm-svn: 150194
* Tests for C++ [expr.prim.lambda]p5. We already implement all of theseDouglas Gregor2012-02-091-3/+57
| | | | | | semantics. llvm-svn: 150190
* Implement return type deduction for lambdas per C++11Douglas Gregor2012-02-091-0/+42
| | | | | | | | | [expr.prim.lambda]p4, including the current suggested resolution of core isue 975, which allows multiple return statements so long as the types match. ExtWarn when user code is actually making use of this extension. llvm-svn: 150168
* Remove the "unsupported" error for lambda expressions. It's annoying,Douglas Gregor2012-02-099-52/+38
| | | | | | and rapidly becoming untrue. llvm-svn: 150165
* Add a test for the non-aggregaticity of lambda types per C++11Douglas Gregor2012-02-091-0/+7
| | | | | | [expr.prim.lambda]. llvm-svn: 150164
* Implement C++ [expr.prim.lambda]p2, which bans lambda expressions inDouglas Gregor2012-02-091-0/+48
| | | | | | | unevaluated operands. Be certain that we're marking everything referenced within a capture initializer as odr-used. llvm-svn: 150163
* Implement capture-by-copy for arrays in lambdas.Douglas Gregor2012-02-092-3/+16
| | | | llvm-svn: 150138
* When we create a non-static data member in the closure object for aDouglas Gregor2012-02-091-0/+17
| | | | | | capture, make sure we actually add the field. llvm-svn: 150135
* Various interrelated cleanups for lambdas:Douglas Gregor2012-02-096-25/+43
| | | | | | | | | | | | | | - Complete the lambda class when we finish the lambda expression (previously, it was left in the "being completed" state) - Actually return the LambdaExpr object and bind to the resulting temporary when needed. - Detect when cleanups are needed while capturing a variable into a lambda (e.g., due to default arguments in the copy constructor), and make sure those cleanups apply for the whole of the lambda expression. llvm-svn: 150123
* Minor comment fixDouglas Gregor2012-02-081-1/+2
| | | | llvm-svn: 150090
* When computing the type of a local variable reference within a lambda,Douglas Gregor2012-02-081-2/+35
| | | | | | | | only add 'const' for variables captured by copy in potentially evaluated expressions of non-mutable lambdas. (The "by copy" part was missing). llvm-svn: 150088
* When completing a lambda expression, make sure to check and attach theDouglas Gregor2012-02-082-2/+14
| | | | | | body of the lambda to the function call operator. llvm-svn: 150087
* Implement DR1458: Taking the address of an object of incomplete class type isRichard Smith2012-02-081-0/+16
| | | | | | | not a constant expression, because we can't tell whether the complete class type will have an overloaded operator&. llvm-svn: 150066
* Add more testing for r149776.Richard Smith2012-02-081-0/+85
| | | | llvm-svn: 150061
* Implement the agreed resolution to DR1457: a signed left shift of a 1 bit intoRichard Smith2012-02-081-2/+5
| | | | | | | | | | the sign bit doesn't have undefined behavior, but a signed left shift of a 1 bit out of the sign bit still does. As promised to Howard :) The suppression of the potential constant expression checking in system headers is also removed, since the problem it was working around is gone. llvm-svn: 150059
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-072-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | - Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures llvm-svn: 149977
* constexpr: Fix implementation of DR1311: check for volatile qualifiers inRichard Smith2012-02-051-9/+8
| | | | | | | lvalue-to-rvalue conversions on the source type of the conversion, not the target type (which has them removed for non-class types). llvm-svn: 149796
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-13/+15
| | | | | | | | | | | | | | | | | | 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
* Implement implicit capture for lambda expressions.Eli Friedman2012-02-031-2/+1
| | | | | | Still left: explicit captures in lambdas need to cause implicit capture, and I need to take a look at the diagnostics for some cases. llvm-svn: 149718
* constexpr:Richard Smith2012-02-021-9/+59
| | | | | | | * support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11 * check for unspecified values in pointer comparisons and pointer subtractions llvm-svn: 149578
* Diagnose the restriction on default arguments in C++11 [expr.prim.lambda]p5.Douglas Gregor2012-02-011-0/+7
| | | | llvm-svn: 149517
* constexpr: check for overflow in pointer subtraction.Richard Smith2012-02-011-1/+9
| | | | | | | | | | | | | This is a mess. According to the C++11 standard, pointer subtraction only has undefined behavior if the difference of the array indices does not fit into a ptrdiff_t. However, common implementations effectively perform a char* subtraction first, and then divide the result by the element size, which can cause overflows in some cases. Those cases are not considered to be undefined behavior by this change; perhaps they should be. llvm-svn: 149490
* constexpr: overflow checking for integral and floating-point arithmetic.Richard Smith2012-02-011-0/+41
| | | | llvm-svn: 149473
* constexpr: require 'this' to point to an object in a constexpr method call.Richard Smith2012-02-011-0/+9
| | | | llvm-svn: 149467
* Improve checking of explicit captures in a C++11 lambda expression:Douglas Gregor2012-02-012-0/+40
| | | | | | | | | | | | | | - Actually building the var -> capture mapping properly (there was an off-by-one error) - Keeping track of the source location of each capture - Minor QoI improvements, e.g, highlighing the prior capture if there are multiple captures, pointing at the variable declaration we found if we reject it. As part of this, add standard citations for the various semantic checks we perform, and note where we're not performing those checks as we should. llvm-svn: 149462
* Diagnose attempts to explicitly capture a __block variable in a lambda.Douglas Gregor2012-02-011-0/+11
| | | | llvm-svn: 149458
* constexpr: Treat INT_MIN % -1 as undefined behavior in C++11. Technically, itRichard Smith2012-01-311-0/+1
| | | | | | isn't, but this is just a (reported) defect in the wording. llvm-svn: 149448
* constexpr: the result of a relational operator between pointers to void isRichard Smith2012-01-311-1/+12
| | | | | | | unspecified unless the pointers are equal; therefore, such a comparison is not a constant expression unless the pointers are equal. llvm-svn: 149366
* constexpr: catch a collection of integral undefined behaviors:Richard Smith2012-01-311-0/+24
| | | | | | | | | -INT_MIN and INT_MIN / -1 Shift by a negative or too large quantity Left shift of negative value Overflow in left shift llvm-svn: 149344
OpenPOWER on IntegriCloud