summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constant-expression-cxx11.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Clarify the diagnostic for -Wnested-anon-types.Richard Smith2013-01-311-2/+2
| | | | llvm-svn: 174032
* Add a -pedantic warning: an anonymous union within an anonymous union is notRichard Smith2013-01-281-2/+2
| | | | | | | permitted in standard C++, despite being silently accepted by many (all?) major C++ implementations. llvm-svn: 173643
* PR11851 (and duplicates): Whenever a constexpr function is referenced,Richard Smith2012-11-071-2/+3
| | | | | | | | | instantiate it if it can be instantiated and implicitly define it if it can be implicitly defined. This matches g++'s approach. Remove some cases from SemaOverload which were marking functions as referenced when just planning how overload resolution would proceed; such cases are not actually references. llvm-svn: 167514
* Partially roll back r166898; it exposed a bug in the standard.Richard Smith2012-10-291-4/+23
| | | | | | | | | | | | | The problem is as follows: C++11 has contexts which are not potentially-evaluated, and yet in which we are required or encouraged to perform constant evaluation. In such contexts, we are not permitted to implicitly define special member functions for literal types, therefore we cannot evalaute those constant expressions. Punt on this in one more context for now by skipping checking constexpr variable initializers if they occur in dependent contexts. llvm-svn: 166956
* When determining whether to try evaluating the initializer of a variable, checkRichard Smith2012-10-281-1/+8
| | | | | | | | | whether the initializer is value-dependent rather than whether we are in a dependent context. This allows us to detect some errors sooner, and fixes a crash-on-invalid if a dependent type leaks out to a non-dependent context in error recovery. llvm-svn: 166898
* PR14171: Don't crash if we hit one of the paths where GetFullTypeForDeclaratorRichard Smith2012-10-241-0/+9
| | | | | | rebuilds a function type, and that function type has parens around its name. llvm-svn: 166644
* DR1535: only potentially-evaluated typeid expressions are disallowed in constantRichard Smith2012-10-171-0/+11
| | | | | | expressions, not *any* typeid on a polymorphic class type. llvm-svn: 166156
* Fix treatment of case which came up on std-proposals@: 'void' is permitted ↵Richard Smith2012-10-011-0/+18
| | | | | | in core constant expressions, despite not being a literal type. llvm-svn: 164968
* Move TLS check from LValueExprEvaluator::VisitVarDecl toHans Wennborg2012-08-291-3/+12
| | | | | | | | | | | CheckLValueConstantExpression. Richard pointed out that using the address of a TLS variable is ok in a core C++11 constant expression, as long as it isn't part of the eventual result of constant expression evaluation. Having the check in CheckLValueConstantExpression accomplishes this. llvm-svn: 162850
* Fix r162835 as per Richard's comments.Hans Wennborg2012-08-291-0/+7
| | | | | | | VisitVarDecl should return Error(E), and we should test that the address of a TLS var can't be used as a constexpr. llvm-svn: 162837
* Implement warning for integral null pointer constants other than the literal 0.David Blaikie2012-08-081-1/+7
| | | | | | | | | | | | | | | | | | | | This is effectively a warning for code that violates core issue 903 & thus will become standard error in the future, hopefully. It catches strange null pointers such as: '\0', 1 - 1, const int null = 0; etc... There's currently a flaw in this warning (& the warning for 'false' as a null pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0' for example). Fix to come in a future patch. Also, due to this only being a warning, not an error, it triggers quite frequently on gtest code which tests expressions for null-pointer-ness in a SFINAE context (so it wouldn't be a problem if this was an error as in an actual implementation of core issue 903). To workaround this for now, the diagnostic does not fire in unevaluated contexts. Review by Sean Silva and Richard Smith. llvm-svn: 161501
* When building a conditional operator where one operand is a throw-expressionRichard Smith2012-08-071-3/+20
| | | | | | | | | and the other is a glvalue of class type, don't forget to copy-initialize a temporary when performing the lvalue-to-rvalue conversion on the glvalue. Strangely, DefaultLvalueConversions misses this part of the lvalue-to-rvalue conversions. llvm-svn: 161450
* Fix crash when constant-evaluating a CXXConstructExpr representingRichard Smith2012-07-101-0/+8
| | | | | | | value-initialization for an array of class type with a trivial default constructor. llvm-svn: 160024
* PR13290: Constant-evaluation support for CXXConstructExprs which construct aRichard Smith2012-07-071-0/+13
| | | | | | | | multidimensional array of class type. Also, preserve zero-initialization when evaluating an initializer list for an array, in case the initializers refer to later elements (which have preceding zero-initialization). llvm-svn: 159904
* PR12670: Support for initializing an array of non-aggregate class type from anRichard Smith2012-07-071-0/+12
| | | | | | | initializer list. Patch by Olivier Goffart, with extra testcases by Meador Inge and Daniel Lunow. llvm-svn: 159896
* PR13273: When performing list-initialization with an empty initializer list,Richard Smith2012-07-051-0/+16
| | | | | | | | | | | actually perform value initialization rather than trying to fake it with a call to the default constructor. Fixes various bugs related to the previously-missing zero-initialization in this case. I've also moved this and the other list initialization 'special case' from TryConstructorInitialization into TryListInitialization where they belong. llvm-svn: 159733
* Additional testing for fixes in r158289 and r158290 to allow implicitly-declaredRichard Smith2012-07-021-0/+25
| | | | | | constructors for non-literal types to be constexpr in some circumstances. llvm-svn: 159513
* Fix lifetime issue for backing APValue of OpaqueValueExpr in recursiveRichard Smith2012-06-261-0/+11
| | | | | | | | | | constexpr function evaluation, and corresponding ASan / valgrind issue in tests, by storing the corresponding value with the relevant stack frame. This also prevents re-evaluation of the source of the underlying OpaqueValueExpr, which makes a major performance difference for certain contrived code (see testcase update). llvm-svn: 159189
* PR12826: Converting an lvalue to an xvalue is a no-op conversion, not an ↵Richard Smith2012-05-151-0/+8
| | | | | | lvalue-to-rvalue conversion. llvm-svn: 156803
* My first effort to do this more subtly failed, so elaboratelyJohn McCall2012-05-011-0/+10
| | | | | | | test for an invalid declaration at every single place in the constant evaluator that's about to request a struct layout. llvm-svn: 155868
* PR12226: don't generate wrong code if a braced string literal is used toRichard Smith2012-04-151-0/+4
| | | | | | | | | initialize an array of unsigned char. Outside C++11 mode, this bug was benign, and just resulted in us emitting a constant which was double the required length, padded with 0s. In C++11, it resulted in us generating an array whose first element was something like i8 ptrtoint ([n x i8]* @str to i8). llvm-svn: 154756
* Allow vectors to be constructed from constexpr function arguments inRichard Smith2012-03-131-0/+14
| | | | | | constant expressions. llvm-svn: 152665
* Add -Wstring-plus-int, which warns on "str" + int and int + "str".Nico Weber2012-03-021-1/+1
| | | | | | | | It doesn't warn if the integer is known at compile time and within the bounds of the string. Discussion: http://comments.gmane.org/gmane.comp.compilers.clang.scm/47203 llvm-svn: 151943
* Ensure that we instantiate static reference data members of class templatesRichard Smith2012-03-021-2/+2
| | | | | | | | | early, since their values can be used in constant expressions in C++11. For odr-use checking, the opposite change is required, since references are odr-used whether or not they satisfy the requirements for appearing in a constant expression. llvm-svn: 151881
* Implement constant expression support for __real__ and __imag__ on lvalueRichard Smith2012-02-181-0/+22
| | | | | | | | | | | | | | | complex numbers. Treat complex numbers as arrays of the corresponding component type, in order to make std::complex behave properly if implemented in terms of _Complex T. Apparently libstdc++'s std::complex is implemented this way, and we were rejecting a member like this: constexpr double real() { return __real__ val; } because it was marked constexpr but unable to produce a constant expression. llvm-svn: 150895
* Fix a problem in the GCC testsuite, exposed by r150557. Compound literalsRichard Smith2012-02-181-0/+10
| | | | | | | are represented as prvalues in C++; don't be fooled into thinking they're global lvalues. llvm-svn: 150870
* Make sure all remaining parts of the constant evaluator are aware that an arrayRichard Smith2012-02-171-0/+6
| | | | | | can be represented by an LValue, and use that to simplify the code a little. llvm-svn: 150789
* constexpr tidyups:Richard Smith2012-02-161-0/+23
| | | | | | | | * Fix bug when determining whether && / || are potential constant expressions * Try harder when determining whether ?: is a potential constant expression * Produce a diagnostic on sizeof(VLA) to provide a better source location llvm-svn: 150657
* Implement DR1454. This allows all intermediate results in constant expressionsRichard Smith2012-02-151-14/+25
| | | | | | | | | | | | 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
* CWG issue 1405: mutable members are allowed in literal types, but can't undergoRichard Smith2012-02-091-0/+24
| | | | | | lvalue-to-rvalue conversions in constant expressions. llvm-svn: 150145
* Implement DR1458: Taking the address of an object of incomplete class type isRichard Smith2012-02-081-1/+2
| | | | | | | not a constant expression, because we can't tell whether the complete class type will have an overloaded operator&. llvm-svn: 150066
* constexpr: Fix implementation of DR1311: check for volatile qualifiers inRichard Smith2012-02-051-4/+10
| | | | | | | 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
* constexpr:Richard Smith2012-02-021-2/+16
| | | | | | | * support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11 * check for unspecified values in pointer comparisons and pointer subtractions llvm-svn: 149578
* constexpr: add support for comparisons of pointer-to-members.Richard Smith2012-02-011-0/+23
| | | | llvm-svn: 149463
* constexpr: Implement the [dcl.constexpr]p5 check for whether a constexprRichard Smith2012-01-271-3/+4
| | | | | | | function definition can produce a constant expression. This also provides the last few checks for [dcl.constexpr]p3 and [dcl.constexpr]p4. llvm-svn: 149108
* constexpr: evaluate (bool)&x as true when x is a local variable or a temporary.Richard Smith2012-01-261-0/+3
| | | | llvm-svn: 149045
* constexpr: add support for anonymous struct and union members in literal types.Richard Smith2012-01-251-0/+40
| | | | llvm-svn: 148987
* Add a test for a diagnostic special case added in r148439, as requested byRichard Smith2012-01-241-0/+19
| | | | | | Francois Pichet. llvm-svn: 148784
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-3/+2
| | | | | | | | | | 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
* The value of a case statement is a potentially evaluated context. Found by ↵Eli Friedman2012-01-181-0/+6
| | | | | | inspection. llvm-svn: 148373
* Enable constant evaluation of implicit calls to constexpr conversion operators.Richard Smith2012-01-171-0/+22
| | | | llvm-svn: 148333
* Pedantic diagnostic correction: in C++, we have integral constant expressions,Richard Smith2012-01-151-9/+8
| | | | | | | | 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
* constexpr: casts to void* are allowed in constant expressions, don't set theRichard Smith2012-01-151-1/+1
| | | | | | | designator invalid. (Since we can't read the value of such a pointer, this only affects the quality of diagnostics.) llvm-svn: 148208
* Fix a silly mistake in ComplexExprEvaluator::ZeroInitialization. ↵Eli Friedman2012-01-131-0/+2
| | | | | | <rdar://problem/10691092>. llvm-svn: 148157
* constexpr: initialization of a union from an empty initializer-list shouldRichard Smith2012-01-121-0/+14
| | | | | | | | | zero-initialize the first union member. Also fix a bug where initializing an array of types compatible with wchar_t from a wide string literal failed in C, and fortify the C++ tests in this area. This part can't be tested without a code change to enable array evaluation in C (where an existing test fails). llvm-svn: 148035
* Implement the missing pieces of Evaluate for _Complex types. With that ↵Eli Friedman2012-01-101-0/+9
| | | | | | complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.) llvm-svn: 147840
* PR11724: Implement evaluation for constexpr defaulted trivial union copy/moveRichard Smith2012-01-101-0/+6
| | | | | | | constructors. These are a special case whose behavior cannot be modeled as a user-written constructor. llvm-svn: 147839
* C++11 generalized constant expressions: implement checking and diagnostics forRichard Smith2012-01-061-25/+24
| | | | | | | 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
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-3/+3
| | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. llvm-svn: 147357
* Fix constexpr handling to allow 'extern constexpr' variable declarations. We noRichard Smith2011-12-251-0/+10
| | | | | | | longer have access to the source locations we need to produce the 'replace constexpr with const' fixits, so they're gone for now. llvm-svn: 147273
OpenPOWER on IntegriCloud