On 11/17/25 4:39 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/dr3045.C: New test.

--- gcc/testsuite/g++.dg/DRs/dr3045.C.jj        2025-11-17 10:46:18.284503308 
+0100
+++ gcc/testsuite/g++.dg/DRs/dr3045.C   2025-11-17 10:46:52.132049586 +0100
@@ -0,0 +1,16 @@
+// DR 3045 - Regularizing environment interactions of expansion statement
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+void
+foo ()
+{
+  static constexpr int arr[] = { 1, 2, 3 };
+  for (auto g : arr) {                         // { dg-message "'int g' previously 
declared here" }
+    int g = 42;                                        // { dg-error "redeclaration 
of 'int g'" }
+  }
+  template for (auto x : arr) {                        // { dg-warning "'template for' only 
available with" "" { target c++23_down } }
+                                               // { dg-message "'int x' previously declared 
here" "" { target *-*-* } .-1 }
+    int x = 42;                                        // { dg-error "redeclaration 
of 'int x'" }
+  }
+}

        Jakub


Reply via email to