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.
--- /dev/null
+// 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 }
+}