summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/static-assert.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] Better static assert diagnostics for expressions involving ↵Clement Courbet2018-12-201-0/+15
| | | | | | | | | | | | | | | | | | temporaries/casts/.... Summary: Handles expressions such as: - `std::is_const<T>()` - `std::is_const<T>()()`; - `std::is_same(decltype(U()), V>::value`; Reviewers: aaron.ballman, Quuxplusone Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D55552 llvm-svn: 349729
* Reland r348741 "[Sema] Further improvements to to static_assert diagnostics."Clement Courbet2018-12-111-2/+10
| | | | | | Fix a dangling reference to temporary, never return nullptr. llvm-svn: 348834
* Revert r348830 "[Sema]improve static_assert(!expr)"Clement Courbet2018-12-111-4/+0
| | | | | | Submitted the wrong change. llvm-svn: 348831
* [Sema]improve static_assert(!expr)Clement Courbet2018-12-111-0/+4
| | | | llvm-svn: 348830
* Revert r348741 "[Sema] Further improvements to to static_assert diagnostics."Clement Courbet2018-12-101-10/+2
| | | | | | Seems to break build bots. llvm-svn: 348742
* [Sema] Further improvements to to static_assert diagnostics.Clement Courbet2018-12-101-2/+10
| | | | | | | | | | | | | | Summary: We're now handling cases like `static_assert(!expr)` and static_assert(!(expr))`. Reviewers: aaron.ballman, Quuxplusone Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55270 llvm-svn: 348741
* [WIP][Sema] Improve static_assert diagnostics for type traits.Clement Courbet2018-12-041-0/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In our codebase, `static_assert(std::some_type_trait<Ts...>::value, "msg")` (where `some_type_trait` is an std type_trait and `Ts...` is the appropriate template parameters) account for 11.2% of the `static_assert`s. In these cases, the `Ts` are typically not spelled out explicitly, e.g. `static_assert(std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value, "message");` The diagnostic when the assert fails is typically not very useful, e.g. `static_assert failed due to requirement 'std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value' "message"` This change makes the diagnostic spell out the types explicitly , e.g. `static_assert failed due to requirement 'std::is_same<int, float>::value' "message"` See tests for more examples. After this is submitted, I intend to handle `static_assert(!std::some_type_trait<Ts...>::value, "msg")`, which is another 6.6% of static_asserts. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54903 llvm-svn: 348239
* Diagnostic specific failed condition in a static_assert.Douglas Gregor2017-09-141-0/+17
| | | | | | | | When a static_assert fails, dig out a specific condition to diagnose, using the same logic that we use to find the enable_if condition to diagnose. llvm-svn: 313315
* Replace remaining user-visible mentions of C++1z with C++17.Richard Smith2017-08-131-1/+1
| | | | llvm-svn: 310804
* Move a test from static-assert.cpp to DeclPrinterTestDavid Majnemer2015-06-051-9/+0
| | | | | | | | It's better not to rely on the diagnostics engine to pretty print the argument to decltype. Instead, exercise the functionality in DeclPrinterTest. llvm-svn: 239197
* [AST] There is no message for C++1z-style static_assertDavid Majnemer2015-06-051-0/+9
| | | | | | | | | | We would crash in the DeclPrinter trying to pretty-print the static_assert message. C++1z-style assertions don't have a message so we would crash. This fixes PR23756. llvm-svn: 239170
* Fix typo in r211394.Richard Smith2014-06-201-1/+1
| | | | llvm-svn: 211395
* [C++1z] Implement N3928: message in static_assert is optional.Richard Smith2014-06-201-0/+3
| | | | llvm-svn: 211394
* Stop instantiating a class if we hit a static_assert failure. Also, if theRichard Smith2012-07-111-0/+14
| | | | | | | static_assert fails when parsing the template, don't diagnose it again on every instantiation. llvm-svn: 160088
* 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-0/+7
| | | | | | | | | | 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
* Produce more detailed diagnostics when static_assert condition is not an ICE.Richard Smith2011-12-141-3/+2
| | | | llvm-svn: 146607
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-2/+2
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Handle static_asserts when instantiating structs.Anders Carlsson2009-03-151-2/+8
| | | | llvm-svn: 67031
* Handle dependent types/exprs in static_assert expressions.Anders Carlsson2009-03-141-0/+9
| | | | llvm-svn: 66997
* More static_assert work. Check that the assert expr is valid and show an ↵Anders Carlsson2009-03-141-0/+15
error if it's false. Create the declaration and add it to the current context. llvm-svn: 66995
OpenPOWER on IntegriCloud