summaryrefslogtreecommitdiffstats
path: root/libcxx/test/language.support
Commit message (Collapse)AuthorAgeFilesLines
* Move test into test/std subdirectory.Eric Fiselier2014-12-20120-5610/+0
| | | | llvm-svn: 224658
* libc++: integral types trap on PNaClJF Bastien2014-11-261-1/+1
| | | | | | | | | | Reviewers: dschuff, danalbert Subscribers: jfb, cfe-commits Differential Revision: http://reviews.llvm.org/D6411 llvm-svn: 222842
* Remove xfail tag for darwin from quick_exit testEric Fiselier2014-11-201-1/+0
| | | | llvm-svn: 222406
* Remove tests that va_copy is not defined when C++ < 11.Eric Fiselier2014-11-201-4/+0
| | | | llvm-svn: 222405
* Change contradictory wording in va_copy test error message.Eric Fiselier2014-11-191-2/+2
| | | | llvm-svn: 222383
* Overhaul and separate nullptr_t tests to pass with C++03.Eric Fiselier2014-11-193-34/+95
| | | | | | | | | | | The standard requires that nullptr_t can be reinterpret_cast to an integral type at least the size of nullptr_t. There is no way to emulate this conversion in the C++03 nullptr_t implementation. The test for this conversion has been moved to a new test and marked XFAIL with c++03. This recommits what was originally r222296. llvm-svn: 222318
* Revert r222296 to fix bad commit messageEric Fiselier2014-11-193-95/+34
| | | | llvm-svn: 222316
* Cleanup quick_exit tests and get them passing in C++03.Eric Fiselier2014-11-193-2/+53
| | | | | | | | | Wrap the original test in _LIBCPP_HAS_QUICK_EXIT so it only runs when we have quick_exit and add two new tests that check that when _LIBCPP_HAS_QUICK_EXIT is not defined then no definition of std::at_quick_exit or std::quick_exit are available. llvm-svn: 222298
* diff --git a/test/language.support/support.types/nullptr_t.pass.cpp ↵Eric Fiselier2014-11-193-34/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | b/test/language.support/support.types/nullptr_t.pass.cpp index 6c15fef..4d7c8b0 100644 --- a/test/language.support/support.types/nullptr_t.pass.cpp +++ b/test/language.support/support.types/nullptr_t.pass.cpp @@ -18,42 +18,62 @@ struct A A(std::nullptr_t) {} }; +template <class T> +void test_conversions() +{ + { + T p = 0; + assert(p == nullptr); + } + { + T p = nullptr; + assert(p == nullptr); + assert(nullptr == p); + assert(!(p != nullptr)); + assert(!(nullptr != p)); + } +} + +template <class T> +void test_comparisons() +{ + T p = nullptr; + assert(p == nullptr); + assert(p <= nullptr); + assert(p >= nullptr); + assert(!(p != nullptr)); + assert(!(p < nullptr)); + assert(!(p > nullptr)); + assert(nullptr == p); + assert(nullptr <= p); + assert(nullptr >= p); + assert(!(nullptr != p)); + assert(!(nullptr < p)); + assert(!(nullptr > p)); +} + + int main() { static_assert(sizeof(std::nullptr_t) == sizeof(void*), "sizeof(std::nullptr_t) == sizeof(void*)"); - A* p = 0; - assert(p == nullptr); - void (A::*pmf)() = 0; -#ifdef __clang__ - // GCC 4.2 can't handle this - assert(pmf == nullptr); -#endif - int A::*pmd = 0; - assert(pmd == nullptr); - A a1(nullptr); - A a2(0); - bool b = nullptr; - assert(!b); - assert(nullptr == nullptr); - assert(nullptr <= nullptr); - assert(nullptr >= nullptr); - assert(!(nullptr != nullptr)); - assert(!(nullptr < nullptr)); - assert(!(nullptr > nullptr)); - A* a = nullptr; - assert(a == nullptr); - assert(a <= nullptr); - assert(a >= nullptr); - assert(!(a != nullptr)); - assert(!(a < nullptr)); - assert(!(a > nullptr)); - assert(nullptr == a); - assert(nullptr <= a); - assert(nullptr >= a); - assert(!(nullptr != a)); - assert(!(nullptr < a)); - assert(!(nullptr > a)); - std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr); - assert(i == 0); + + { + test_conversions<std::nullptr_t>(); + test_conversions<void*>(); + test_conversions<A*>(); + test_conversions<void(*)()>(); + test_conversions<void(A::*)()>(); + test_conversions<int A::*>(); + } + { + test_comparisons<std::nullptr_t>(); + test_comparisons<void*>(); + test_comparisons<A*>(); + test_comparisons<void(*)()>(); + } + { + bool b = nullptr; + assert(!b); + } } diff --git a/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp b/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp new file mode 100644 index 0000000..92bd879 --- /dev/null +++ b/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// typedef decltype(nullptr) nullptr_t; + +#include <cstddef> + +int main() +{ + std::ptrdiff_t i = static_cast<std::ptrdiff_t>(nullptr); +} diff --git a/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp b/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp new file mode 100644 index 0000000..34c7a93 --- /dev/null +++ b/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an +// integral type +// XFAIL: c++98, c++03 + +// typedef decltype(nullptr) nullptr_t; + + +#include <cstddef> +#include <cassert> + +int main() +{ + std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr); + assert(i == 0); +} llvm-svn: 222296
* Modify tests to check that va_copy is only defined in C++11 and beyond.Eric Fiselier2014-11-181-2/+8
| | | | llvm-svn: 222282
* Mark more tests as UNSUPPORTED with ASAN and MSAN.Eric Fiselier2014-11-144-2/+12
| | | | | | | | | | These tests fail for 2 reasons when using ASAN and MSAN. 1. If allocator_may_return_null=0 they will fail because null is returned or an exception is thrown. 2. When allocator_may_return_null=1 the new_handler is still not called. This results in an assertion failures. llvm-svn: 221967
* Actually mark the tests an unsupported with MSAN (not just ASAN)Eric Fiselier2014-11-044-4/+4
| | | | llvm-svn: 221240
* Mark tests that replace operator new/delete as UNSUPPORTED with ASAN and MSAN.Eric Fiselier2014-11-046-6/+16
| | | | | | | tests that replace operator new/delete won't link when using ASAN and MSAN because these sanitizers also replace new/delete. llvm-svn: 221236
* Some tests used __typeof__ instead of decltype. Replace these usages.Marshall Clow2014-10-211-2/+2
| | | | llvm-svn: 220296
* Fix numeric_limits<XXX>::is_modulo for signed arithmetic types. We were ↵Marshall Clow2014-07-311-8/+8
| | | | | | reporting true, for all arithmetic types, which is incorrect. Fix the tests which were wrong, too. This fixes PR#20158. llvm-svn: 214371
* [libc++] Teach is_integral, is_[un]signed and make_[un]signed about ↵Stephan Tolksdorf2014-03-2633-0/+142
| | | | | | | | | | __[u]int128_t This commit also adds tests for std::numeric_limits<__[u]int128_t>. Reviewed in http://llvm-reviews.chandlerc.com/D2917 llvm-svn: 204849
* Fix numeric.limits.members/traps.pass.cpp to pass on non-x86 architectures. ↵Marshall Clow2014-02-031-14/+20
| | | | | | Fixes bug #18468 llvm-svn: 200724
* Removed extra line that I left in when committing 199694. Thanks to Jared ↵Marshall Clow2014-01-261-1/+0
| | | | | | Grubb for the catch. llvm-svn: 200108
* Removed extra space; thanks to thakis_'s eagle eyeMarshall Clow2014-01-211-1/+1
| | | | llvm-svn: 199695
* Fixed test failure in is_iec559.pass.cpp on darwin-ppc32. Thanks to David ↵Marshall Clow2014-01-201-0/+5
| | | | | | Fang for the report (and suggested fix) llvm-svn: 199694
* Remove executable permissions on a text fileSylvestre Ledru2013-12-011-0/+0
| | | | llvm-svn: 196041
* Test for 'bad_array_length'; got left out of initial commitMarshall Clow2013-09-121-0/+29
| | | | llvm-svn: 190614
* Apply constexpr to initializer_list for c++1y.Howard Hinnant2013-08-263-0/+43
| | | | llvm-svn: 189271
* A few fixes to tests for Windows port.Howard Hinnant2013-07-152-2/+2
| | | | llvm-svn: 186334
* War on tabs.Howard Hinnant2013-07-081-4/+4
| | | | llvm-svn: 185865
* [tests] XFAIL a few things that require libc (?) support missing on Darwin.Daniel Dunbar2013-02-051-0/+2
| | | | llvm-svn: 174450
* Make a few tests optimization-proof. These tests were failing under -O3 ↵Howard Hinnant2013-01-164-4/+4
| | | | | | because the optimizer was eliminating the call to new. llvm-svn: 172631
* Zhang Xiongpang: Add definitions for const data members. Fixes ↵Howard Hinnant2012-12-121-0/+185
| | | | | | http://llvm.org/bugs/show_bug.cgi?id=14585. llvm-svn: 170026
* Add noexcept test for offsetof macro per [support.types]/p4.Howard Hinnant2012-07-061-0/+8
| | | | llvm-svn: 159846
* Don't refer to a function that doesn't exist in the quick_exit test.David Chisnall2012-03-141-1/+1
| | | | llvm-svn: 152716
* Fixed PR10574: http://llvm.org/bugs/show_bug.cgi?id=10574Howard Hinnant2011-08-124-2/+14
| | | | llvm-svn: 137522
* Give A an explicitly non-throwing destructor so that B's destructor isAlexis Hunt2011-07-181-1/+1
| | | | | | | | | | itself non-throwing. Since nested_exception's destructor is non-throwing, if B's destructor is not, this causes an error in C++03 mode due to the overriding function having a more lax specification. This did not occur in C++0x mode as A's destructor was implicitly non-throwing. llvm-svn: 135400
* <rdar://problem/9073695> std::uncaught_exception() becomes true before ↵Nick Kledzik2011-03-111-1/+10
| | | | | | evaluating the throw-expression rather than after llvm-svn: 127499
* Corrected const-correctness on nullptr type_traits, and beefed up the test ↵Howard Hinnant2011-03-091-0/+15
| | | | | | for nullptr_t. llvm-svn: 127338
* N3189 Observers for the three handler functionsHoward Hinnant2010-12-022-0/+50
| | | | llvm-svn: 120712
* license changeHoward Hinnant2010-11-16112-224/+224
| | | | llvm-svn: 119395
* I have reverted all contributions made by Jesse Towner in revision 110724Howard Hinnant2010-11-161-20/+3
| | | | llvm-svn: 119383
* sync with N3126Howard Hinnant2010-09-054-92/+0
| | | | llvm-svn: 113098
* sync with N3126Howard Hinnant2010-09-051-0/+0
| | | | llvm-svn: 113097
* Changed __config to react to all of clang's currently documented has_feature ↵Howard Hinnant2010-09-042-2/+2
| | | | | | flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature. llvm-svn: 113086
* Remove tabsHoward Hinnant2010-08-221-7/+7
| | | | llvm-svn: 111778
* Fixing whitespace problemsHoward Hinnant2010-08-2252-54/+54
| | | | llvm-svn: 111760
* patch by Jesse Towner, and bug fix by Sebastian RedlHoward Hinnant2010-08-101-2/+19
| | | | llvm-svn: 110724
* [support.initlist.range]Howard Hinnant2010-05-281-0/+36
| | | | llvm-svn: 104975
* Corrected rethrow_if_nestedHoward Hinnant2010-05-281-12/+28
| | | | llvm-svn: 104943
* [except.nested]Howard Hinnant2010-05-276-0/+417
| | | | llvm-svn: 104850
* change test case to verify unexpected() calls terminate - not is terminateNick Kledzik2010-05-141-2/+15
| | | | llvm-svn: 103794
* Wiped out some non-ascii characters that snuck into the copyright.Howard Hinnant2010-05-11109-109/+109
| | | | llvm-svn: 103516
* libcxx initial importHoward Hinnant2010-05-11109-0/+4582
llvm-svn: 103490
OpenPOWER on IntegriCloud