diff mbox series

C++ PATCH to add test for DR 2345

Message ID 20190921140236.GW14737@redhat.com
State New
Headers show
Series C++ PATCH to add test for DR 2345 | expand

Commit Message

Marek Polacek Sept. 21, 2019, 2:02 p.m. UTC
Jumping across initializers is forbidden, and this DR clarifies that
that applies to initializers in init-statements too.  We already detect
this case, so I'm adding this test and marking the DR as resolved.

Tested on x86_64-linux, applying to trunk.

2019-09-21  Marek Polacek  <polacek@redhat.com>

	DR 2345 - Jumping across initializers in init-statements and conditions.
	* g++.dg/cpp1z/init-statement10.C: New test.
diff mbox series

Patch

diff --git gcc/testsuite/g++.dg/cpp1z/init-statement10.C gcc/testsuite/g++.dg/cpp1z/init-statement10.C
new file mode 100644
index 00000000000..d13d135dab1
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/init-statement10.C
@@ -0,0 +1,14 @@ 
+// DR 2345 - Jumping across initializers in init-statements and conditions.
+// { dg-do compile { target c++17 } }
+
+int
+fn ()
+{
+  goto X;
+  if (int i = 42; i == 42)
+    {
+X: // { dg-error "jump to label" }
+      return i;
+    }
+  return -1;
+}