summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constexpr-printing.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [c++20] Implement semantic restrictions for C++20 designatedRichard Smith2019-08-301-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initializers. This has some interesting interactions with our existing extensions to support C99 designated initializers as an extension in C++. Those are resolved as follows: * We continue to permit the full breadth of C99 designated initializers in C++, with the exception that we disallow a partial overwrite of an initializer with a non-trivially-destructible type. (Full overwrite is OK, because we won't run the first initializer at all.) * The C99 extensions are disallowed in SFINAE contexts and during overload resolution, where they could change the meaning of valid programs. * C++20 disallows reordering of initializers. We only check for that for the simple cases that the C++20 rules permit (designators of the form '.field_name =' and continue to allow reordering in other cases). It would be nice to improve this behavior in future. * All C99 designated initializer extensions produce a warning by default in C++20 mode. People are going to learn the C++ rules based on what Clang diagnoses, so it's important we diagnose these properly by default. * In C++ <= 17, we apply the C++20 rules rather than the C99 rules, and so still diagnose C99 extensions as described above. We continue to accept designated C++20-compatible initializers in C++ <= 17 silently by default (but naturally still reject under -pedantic-errors). This is not a complete implementation of P0329R4. In particular, that paper introduces new non-C99-compatible syntax { .field { init } }, and we do not support that yet. This is based on a previous patch by Don Hinton, though I've made substantial changes when addressing the above interactions. Differential Revision: https://reviews.llvm.org/D59754 llvm-svn: 370544
* Revert "Lexer: always allow imaginary constants in GNU mode."Tim Northover2017-08-081-1/+1
| | | | | | | This reverts r310423. It was committed by mistake, I intended to commit the improved diagnostics for implicit conversions instead. llvm-svn: 310426
* Lexer: always allow imaginary constants in GNU mode.Tim Northover2017-08-081-1/+1
| | | | llvm-svn: 310423
* PR17381: Treat undefined behavior during expression evaluation as an unmodeledRichard Smith2015-12-031-1/+3
| | | | | | | | | | | | | | | | | | | | | side-effect, so that we don't allow speculative evaluation of such expressions during code generation. This caused a diagnostic quality regression, so fix constant expression diagnostics to prefer either the first "can't be constant folded" diagnostic or the first "not a constant expression" diagnostic depending on the kind of evaluation we're doing. This was always the intent, but didn't quite work correctly before. This results in certain initializers that used to be constant initializers to no longer be; in particular, things like: float f = 1e100; are no longer accepted in C. This seems appropriate, as such constructs would lead to code being executed if sanitizers are enabled. llvm-svn: 254574
* Revert "Don't require -re suffix on -verify directives with regexes."Alp Toker2013-12-141-2/+2
| | | | | | | | | | This patch was submitted to the list for review and didn't receive a LGTM. (In fact one explicit objection and one query were raised.) This reverts commit r197295. llvm-svn: 197299
* Don't require -re suffix on -verify directives with regexes.Hans Wennborg2013-12-141-2/+2
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2392 llvm-svn: 197295
* C++1y: support simple variable assignments in constexpr functions.Richard Smith2013-04-261-1/+1
| | | | llvm-svn: 180603
* Add triples to these tests to keep them working on Windows,Richard Smith2012-04-051-1/+1
| | | | | | where wchar_t is only 16 bits wide. llvm-svn: 154072
* Fix assertions and wrong output from StmtPrinter's string literal printing.Richard Smith2012-04-051-2/+2
| | | | | | | | | | String literals (including unicode ones) can contain non-Unicode codepoints if they were written using \x or similar. Write those out using \x, but be careful that the following character can't be misinterpreted as part of the \x escape sequence. Convert UTF-16 surrogate pairs back to codepoints before rendering them. llvm-svn: 154069
* Teach APValue printer to print boolean 0 and 1 as 'false' and 'true'. Fix upRichard Smith2012-03-231-0/+4
| | | | | | some calling code to actually pass in a non-null type, to avoid a crash. llvm-svn: 153358
* Address Richard's review comments on r147561 (Evaluate support for ↵Eli Friedman2012-01-051-0/+7
| | | | | | address-of-label differences). llvm-svn: 147631
* Add assertion to char32_t that the value is valid, as suggested by Jordy Rose.Richard Smith2012-01-021-2/+4
| | | | | | | Add a test that such characters don't make it through to StringLiteral objects in error recovery. llvm-svn: 147438
* Fix crash when trying to pretty-print unicode or wide string literals.Richard Smith2011-12-301-0/+14
| | | | llvm-svn: 147385
* Unrevert r147271, reverted in r147361.Richard Smith2011-12-301-2/+5
| | | | | | | | | | | | 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-5/+2
| | | | llvm-svn: 147362
* constexpr: perform zero-initialization prior to / instead of performing aRichard Smith2011-12-251-2/+5
| | | | | | 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-9/+7
| | | | | | constant expressions. llvm-svn: 147035
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-4/+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
* C++11 constexpr: Add note stacks containing backtraces if constant evaluationRichard Smith2011-12-161-0/+73
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
OpenPOWER on IntegriCloud