On 11/17/25 4:40 PM, Jakub Jelinek wrote:
Hi!
Working virtually out of Beaker Island.
We already implement expansion statements that way, the following patch
just adds a testcase for it.
Tested on x86_64-linux and i686-linux, ok for trunk?
OK.
2025-11-17 Jakub Jelinek <[email protected]>
* g++.dg/DRs/dr3061.C: New test.
--- gcc/testsuite/g++.dg/DRs/dr3061.C.jj 2025-11-17 10:50:28.868144259
+0100
+++ gcc/testsuite/g++.dg/DRs/dr3061.C 2025-11-17 10:52:53.760201985 +0100
@@ -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 }
+}
Jakub