DR 2345 - Jumping across initializers in init-statements and conditions.
authorMarek Polacek <polacek@redhat.com>
Sat, 21 Sep 2019 13:59:29 +0000 (13:59 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sat, 21 Sep 2019 13:59:29 +0000 (13:59 +0000)
* g++.dg/cpp1z/init-statement10.C: New test.

From-SVN: r276019

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/init-statement10.C [new file with mode: 0644]

index d0c01e3138b3797beb2bc374f72684d9409ba7f9..36e0b2b96017ddf78084dd60cfdd98e334edf8ca 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2019-09-21  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.target/aarch64/sve/cond_convert_1.c: Remove XFAILs.
diff --git a/gcc/testsuite/g++.dg/cpp1z/init-statement10.C b/gcc/testsuite/g++.dg/cpp1z/init-statement10.C
new file mode 100644 (file)
index 0000000..d13d135
--- /dev/null
@@ -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;
+}