]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add testcase for CWG3061
authorJakub Jelinek <jakub@redhat.com>
Mon, 17 Nov 2025 14:26:22 +0000 (15:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 17 Nov 2025 14:26:22 +0000 (15:26 +0100)
We already implement expansion statements that way, the following patch
just adds a testcase for it.

2025-11-17  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr3061.C: New test.

gcc/testsuite/g++.dg/DRs/dr3061.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/DRs/dr3061.C b/gcc/testsuite/g++.dg/DRs/dr3061.C
new file mode 100644 (file)
index 0000000..7288298
--- /dev/null
@@ -0,0 +1,18 @@
+// DR 3061 - Trailing comma in an expansion-init-list
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+#include <initializer_list>
+
+void
+foo ()
+{
+  for (int x : { 1, })
+    ;
+  template for (int x : { 1, })                // { dg-warning "'template for' only available with" "" { target c++23_down } }
+    ;
+  for (int x : { , })                  // { dg-error "expected primary-expression before ',' token" }
+    ;                                  // { dg-error "unable to deduce" "" { target *-*-* } .-1 }
+  template for (int x : { , })         // { dg-warning "'template for' only available with" "" { target c++23_down } }
+    ;                                  // { dg-error "expected primary-expression before ',' token" "" { target *-*-* } .-1 }
+}