https://gcc.gnu.org/g:301fcc7b48bb607a0da7c6bccd2677058b03c851

commit r16-5338-g301fcc7b48bb607a0da7c6bccd2677058b03c851
Author: Jakub Jelinek <[email protected]>
Date:   Mon Nov 17 15:26:22 2025 +0100

    c++: Add testcase for CWG3061
    
    We already implement expansion statements that way, the following patch
    just adds a testcase for it.
    
    2025-11-17  Jakub Jelinek  <[email protected]>
    
            * g++.dg/DRs/dr3061.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/DRs/dr3061.C | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gcc/testsuite/g++.dg/DRs/dr3061.C 
b/gcc/testsuite/g++.dg/DRs/dr3061.C
new file mode 100644
index 000000000000..728829848f54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr3061.C
@@ -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 }
+}

Reply via email to