aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C
new file mode 100644
index 000000000..2115627ef
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/other/no-strict-enum-precision-1.C
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* { dg-options "-fno-strict-enums" } */
+
+extern "C" void abort (void);
+
+enum zero_one
+{ zero = 0, one = 1 };
+
+int *
+allocate_bool (zero_one e)
+{
+ int *v = 0;
+ switch (e)
+ {
+ case zero:
+ v = new int (0);
+ case one:
+ v = new int (1);
+ }
+ return v;
+}
+
+int
+main ()
+{
+ if (allocate_bool (static_cast < zero_one > (999)))
+ {
+ /* Error: should not have matched any case label. */
+ abort ();
+ }
+ else
+ {
+ return 0;
+ }
+}