diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/opt/enum2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/opt/enum2.C | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/enum2.C b/gcc/testsuite/g++.dg/opt/enum2.C new file mode 100644 index 00000000000..6300896cff9 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/enum2.C @@ -0,0 +1,21 @@ +// PR c++/43680 +// Test that we don't make excessively aggressive assumptions about what +// values an enum variable can have. +// { dg-options "-O2 -fPIC" } +// { dg-do run } + +extern "C" void abort (); + +enum E { A, B, C, D }; + +void +CheckE(const E value) +{ + long v = value; + if (v <= D) + abort (); +} + +int main() { + CheckE(static_cast<E>(5)); +} |