diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-01-08 23:15:49 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-01-08 23:15:49 +0000 |
commit | 416f555930c2eb2fbfb6edb8219cf090d0bd5e74 (patch) | |
tree | 9764ddb234997b1419caac7700530b89d4f862e1 | |
parent | d942bc80e4e99f26df39b8c03e8fb03e7c7e91bc (diff) | |
download | gcc-416f555930c2eb2fbfb6edb8219cf090d0bd5e74.zip gcc-416f555930c2eb2fbfb6edb8219cf090d0bd5e74.tar.gz gcc-416f555930c2eb2fbfb6edb8219cf090d0bd5e74.tar.bz2 |
Pretty printer test fixes and improvements
Test that StdUniquePtrPrinter correctly prints std::unique_ptr objects
using the old layout, prior to the PR libstdc++/77990 changes.
The printer test for a valueless std::variant started to fail because
the PR libstdc++/87431 fix meant it no longer became valueless. Change
the test to use a type that is not trivially copyable, so that the
exception causes it to become valueless.
* testsuite/libstdc++-prettyprinters/compat.cc: Test printer support
for old std::unique_ptr layout.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Fix std::variant test
to become valueless. Add filesystem::path tests.
From-SVN: r267743
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc | 22 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc | 17 |
3 files changed, 42 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bb8f874..f1aa1c3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2019-01-08 Jonathan Wakely <jwakely@redhat.com> + * testsuite/libstdc++-prettyprinters/compat.cc: Test printer support + for old std::unique_ptr layout. + * testsuite/libstdc++-prettyprinters/cxx17.cc: Fix std::variant test + to become valueless. Add filesystem::path tests. + PR libstdc++/87855 * include/std/optional (_Optional_payload_base): New class template for common code hoisted from _Optional_payload specializations. Use diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc index 39271dd..a538b85 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc @@ -23,6 +23,22 @@ namespace std { + template<typename T, typename U> + struct tuple + { + T _M_head_impl; + }; + + template<typename T> struct default_delete { }; + + template<typename T, typename D = default_delete<T>> + struct unique_ptr + { + unique_ptr(T* p) { _M_t._M_head_impl = p; } + + tuple<T*, D> _M_t; + }; + // Old representation of std::optional, before GCC 9 template<typename T> struct _Optional_payload @@ -58,6 +74,12 @@ namespace std int main() { + struct datum { }; + std::unique_ptr<datum> uptr (new datum); +// { dg-final { regexp-test uptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } } + std::unique_ptr<datum> &ruptr = uptr; +// { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } } + using std::optional; optional<int> o; diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc index 7e6f45b..c550cbd 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc @@ -22,6 +22,7 @@ // Type printers only recognize the old std::string for now. #define _GLIBCXX_USE_CXX11_ABI 0 +#include <filesystem> #include <any> #include <optional> #include <variant> @@ -41,6 +42,11 @@ using std::unordered_set; using std::shared_ptr; using std::weak_ptr; +struct X { + X(int) { } + X(const X&) { } // not trivially-copyable +}; + int main() { @@ -84,11 +90,11 @@ main() // { dg-final { note-test v0 {std::variant<float, int, std::string_view> [index 0] = {0}} } } variant<float, int, string_view> v1{ 0.5f }; // { dg-final { note-test v1 {std::variant<float, int, std::string_view> [index 0] = {0.5}} } } - variant<float, int, string_view> v2; + variant<float, X, string_view> v2; try { v2.emplace<1>(S()); } catch (int) { } -// { dg-final { note-test v2 {std::variant<float, int, std::string_view> [no contained value]} } } +// { dg-final { note-test v2 {std::variant<float, X, std::string_view> [no contained value]} } } variant<float, int, string_view> v3{ 3 }; // { dg-final { note-test v3 {std::variant<float, int, std::string_view> [index 1] = {3}} } } variant<float, int, string_view> v4{ str }; @@ -118,6 +124,13 @@ main() // { dg-final { regexp-test q {std::shared_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } } // { dg-final { regexp-test wq {std::weak_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } } + std::filesystem::path p0; +// { dg-final { note-test p0 {filesystem::path ""} } } + std::filesystem::path p1("filename"); +// { dg-final { note-test p1 {filesystem::path "filename"} } } + std::filesystem::path p2("/dir/."); +// { dg-final { note-test p2 {filesystem::path "/dir/file" = {[root-directory] = "/", [1] = "dir", [2] = "."}} } } + std::cout << "\n"; return 0; // Mark SPOT } |