Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/scoped_enum_examples.C

raw
1 // { dg-do compile { target c++11 } }
2 enum class Col { red, yellow, green };
3
4 int x = Col::red; // { dg-error "cannot convert" }
5 Col y = Col::red;
6
7 void f()
8 {
9 if (y) { } // { dg-error "could not convert" }
10 }
11
12 enum direction { left='l', right='r' };
13 void g() {
14 // OK
15 direction d;
16 // OK
17 d = left;
18 // OK
19 d = direction::right;
20 }
21 enum class altitude { high='h', low='l' };
22 void h() {
23 altitude a;
24 a = high; // { dg-error "not declared in this scope" }
25 a = altitude::low;
26 }