* [committed] C++ PATCH to add test for c++/87523
@ 2018-12-01 22:01 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2018-12-01 22:01 UTC (permalink / raw)
To: GCC Patches
Tested x86_64-linux, applying to trunk.
2018-12-01 Marek Polacek <polacek@redhat.com>
PR c++/87523
* g++.dg/cpp1y/lambda-generic-87523.C: New test.
diff --git gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C
new file mode 100644
index 00000000000..ecba1cfc322
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-87523.C
@@ -0,0 +1,32 @@
+// PR c++/87523
+// { dg-do compile { target c++14 } }
+
+template <typename T, T v>
+struct my_integer_constant {
+ constexpr my_integer_constant() {}
+ constexpr operator T() const { return v; }
+ constexpr T operator()() const { return v; }
+};
+
+template <typename T, T... u>
+struct constant_call {
+ template <typename Callback>
+ static void call(T v, Callback f) {
+ char dummy[sizeof...(u)] = { ( (v == u) ? (f(my_integer_constant<T, u>{}), static_cast<char>(0)) : static_cast<char>(0))... };
+ (void)dummy;
+ }
+};
+
+void f(bool reverse_in, bool other_bool_in) {
+ auto helper = [&] (auto reverse_t) {
+ bool constexpr reverse_v = reverse_t;
+ (void)reverse_v;
+ constant_call<bool, true, false>::call(other_bool_in,
+ [&] (auto newb) {
+ bool reverse_v_dyn = reverse_v;
+ });
+ };
+ constant_call<bool, true, false>::call(reverse_in, [&] (auto reverse_t) {
+ helper(reverse_t);
+ });
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-01 22:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-01 22:01 [committed] C++ PATCH to add test for c++/87523 Marek Polacek
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).