diff mbox series

C++ PATCH to add test for c++/91104

Message ID 20190717175123.GF32749@redhat.com
State New
Headers show
Series C++ PATCH to add test for c++/91104 | expand

Commit Message

Marek Polacek July 17, 2019, 5:51 p.m. UTC
This was a wrong code issue where we printed
2 3 1
1 2 3
instead of
1 2 3
1 2 3
but it was fixed by r271705.  I don't know of a good way to check
the auto... expansion here so I used dg-output.

Tested on x86_64-linux, ok for trunk?

2019-07-17  Marek Polacek  <polacek@redhat.com>

	PR c++/91104
	* g++.dg/cpp1y/lambda-generic-variadic20.C: New test.

Comments

Jason Merrill July 31, 2019, 6:53 p.m. UTC | #1
On 7/17/19 1:51 PM, Marek Polacek wrote:
> This was a wrong code issue where we printed
> 2 3 1
> 1 2 3
> instead of
> 1 2 3
> 1 2 3
> but it was fixed by r271705.  I don't know of a good way to check
> the auto... expansion here so I used dg-output.

You could call another function with the expansion and check the 
arguments there?

Jason
diff mbox series

Patch

--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic20.C
@@ -0,0 +1,20 @@ 
+// PR c++/91104
+// { dg-do run { target c++14 } }
+
+#include <cstdio>
+
+void test(void (*f)(int, int, int)) {
+    f(1, 2, 3);
+}
+
+int main() {
+    test([](auto... args) {
+        printf("%d %d %d\n", args...);
+    });
+    test([](int a, int b, int c) {
+        printf("%d %d %d\n", a, b, c);
+    });
+}
+
+// { dg-output "1 2 3(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*1 2 3" }