* [committed] libstdc++: Add test for type traits not having friend access
@ 2022-09-24 0:07 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-09-24 0:07 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested powerpc64le-linux. Pushed to trunk.
-- >8 --
This ensures that the std::is_assignable and std::is_assignable_v
traits are evaluated "in a context unrelated" to the argument types.
libstdc++-v3/ChangeLog:
* testsuite/20_util/is_assignable/requirements/access.cc:
New test.
---
.../is_assignable/requirements/access.cc | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc
diff --git a/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc
new file mode 100644
index 00000000000..a96fba654cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc
@@ -0,0 +1,22 @@
+// { dg-do compile { target c++11 } }
+
+#include <type_traits>
+
+class S {
+ operator int();
+ friend void g(); // #1
+};
+
+void
+g()
+{
+ int i = 0;
+ S s;
+ i = s; // this works, because we're inside a friend.
+
+ // But the traits are evaluated in "a context unrelated to either type".
+ static_assert( ! std::is_assignable<int&, S>::value, "unfriendly");
+#if __cplusplus >= 201703L
+ static_assert( ! std::is_assignable_v<int&, S>, "unfriendly");
+#endif
+}
--
2.37.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-24 0:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-24 0:07 [committed] libstdc++: Add test for type traits not having friend access Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).