aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/19_diagnostics
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-04-11 13:36:47 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-04-11 15:53:22 +0100
commitc62b0f731b32c1842bb679edc5b8d842b5e5732f (patch)
tree5f83c1d010346c7743a6fece10c02e4153403b2c /libstdc++-v3/testsuite/19_diagnostics
parent0df39b08037f78dfc53c3c4e6c09b3babe6ee0f8 (diff)
downloadgcc-c62b0f731b32c1842bb679edc5b8d842b5e5732f.zip
gcc-c62b0f731b32c1842bb679edc5b8d842b5e5732f.tar.gz
gcc-c62b0f731b32c1842bb679edc5b8d842b5e5732f.tar.bz2
libstdc++: Move stacktrace tests to 19_diagnostics directory
This matches where the feature is defined in the current draft. libstdc++-v3/ChangeLog: * testsuite/20_util/stacktrace/entry.cc: Moved to... * testsuite/19_diagnostics/stacktrace/entry.cc: ...here. * testsuite/20_util/stacktrace/synopsis.cc: Moved to... * testsuite/19_diagnostics/stacktrace/synopsis.cc: ...here. * testsuite/20_util/stacktrace/version.cc: Moved to... * testsuite/19_diagnostics/stacktrace/version.cc: ...here.
Diffstat (limited to 'libstdc++-v3/testsuite/19_diagnostics')
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc53
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc46
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/stacktrace/version.cc11
3 files changed, 110 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
new file mode 100644
index 0000000..0bbcabd
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
@@ -0,0 +1,53 @@
+// { dg-options "-std=gnu++23 -lstdc++_libbacktrace" }
+// { dg-do run { target c++23 } }
+// { dg-require-effective-target stacktrace }
+
+#include <stacktrace>
+#include "testsuite_hooks.h"
+
+static_assert( std::regular<std::stacktrace_entry> );
+static_assert( std::three_way_comparable<std::stacktrace_entry> );
+
+constexpr bool
+test_constexpr()
+{
+ std::stacktrace_entry empty;
+ VERIFY( !empty );
+ VERIFY( empty == empty );
+ VERIFY( std::is_eq(empty <=> empty) );
+
+ std::stacktrace_entry::native_handle_type native = empty.native_handle();
+ VERIFY( empty.native_handle() == native );
+
+ return true;
+}
+static_assert( test_constexpr() );
+
+void
+test_members()
+{
+ std::stacktrace_entry empty;
+ VERIFY( empty.description().size() == 0 );
+ VERIFY( empty.source_file().size() == 0 );
+ VERIFY( empty.source_line() == 0 );
+
+ std::stacktrace_entry e1 = std::stacktrace::current().at(0);
+ std::stacktrace_entry e2 = std::stacktrace::current().at(0);
+ VERIFY( e1 != e2 );
+ VERIFY( e1.description() == e2.description() );
+ VERIFY( e1.source_file() == e2.source_file() );
+ VERIFY( e1.source_line() != e2.source_line() );
+
+ std::stacktrace_entry e3 = []{
+ return std::stacktrace::current().at(0);
+ }();
+ VERIFY( e1 != e3 );
+ VERIFY( e1.description() != e3.description() );
+ VERIFY( e1.source_file() == e3.source_file() );
+ VERIFY( e1.source_line() != e3.source_line() );
+}
+
+int main()
+{
+ test_constexpr();
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc
new file mode 100644
index 0000000..72582fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+// { dg-require-effective-target stacktrace }
+
+#include <stacktrace>
+
+#ifndef __cpp_lib_stacktrace
+# error "Feature-test macro for stacktrace missing in <stacktrace>"
+#elif __cpp_lib_stacktrace < 202011L
+# error "Feature-test macro for stacktrace has wrong value in <stacktrace>"
+#endif
+
+namespace std
+{
+ class stacktrace_entry;
+
+ template<class Allocator>
+ class basic_stacktrace;
+
+ using stacktrace = basic_stacktrace<allocator<stacktrace_entry>>;
+
+ template<class Allocator>
+ void swap(basic_stacktrace<Allocator>& a, basic_stacktrace<Allocator>& b)
+ noexcept(noexcept(a.swap(b)));
+
+ string to_string(const stacktrace_entry& f);
+
+ template<class Allocator>
+ string to_string(const basic_stacktrace<Allocator>& st);
+
+ template<class charT, class traits>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const stacktrace_entry& f);
+
+ template<class charT, class traits, class Allocator>
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os, const basic_stacktrace<Allocator>& st);
+
+ namespace pmr {
+ using stacktrace = basic_stacktrace<polymorphic_allocator<stacktrace_entry>>;
+ }
+
+ template<class T> struct hash;
+ template<> struct hash<stacktrace_entry>;
+ template<class Allocator> struct hash<basic_stacktrace<Allocator>>;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/version.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/version.cc
new file mode 100644
index 0000000..ed466be
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/version.cc
@@ -0,0 +1,11 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do preprocess { target c++23 } }
+// { dg-require-effective-target stacktrace }
+
+#include <version>
+
+#ifndef __cpp_lib_stacktrace
+# error "Feature-test macro for stacktrace missing in <version>"
+#elif __cpp_lib_stacktrace < 202011L
+# error "Feature-test macro for stacktrace has wrong value in <version>"
+#endif