summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/forw_enum5.C
blob: a2edfa7635c50b4be504d6bc51d36fe545389c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// { dg-do compile }
// { dg-options "-std=c++0x" }

namespace one
{
    struct S
    {
        enum { A = 1, B = 2 };
        struct T
        {
            enum { B = 102 };

            enum class E1;
            enum E2 : int;
        };
    };

    enum class S::T::E1 { A1 = A, B1 = B, C1 };
    enum S::T::E2 : int { A1 = A, B1 = B, C1 };

    static_assert(int(S::T::E1::A1) == 1, "error");
    static_assert(int(S::T::E1::B1) == 102, "error");
    static_assert(int(S::T::E1::C1) == 103, "error");

    static_assert(int(S::T::E2::A1) == 1, "error");
    static_assert(int(S::T::E2::B1) == 102, "error");
    static_assert(int(S::T::E2::C1) == 103, "error");
    static_assert(int(S::T::A1) == 1, "error");
    static_assert(int(S::T::B1) == 102, "error");
    static_assert(int(S::T::C1) == 103, "error");
}


namespace two
{
    namespace S
    {
        enum { A = 1, B = 2 };
        namespace T
        {
            enum { B = 102 };

            enum class E1;
            enum E2 : int;
        }
    }

    enum class S::T::E1 { A1 = A, B1 = B, C1 };
    enum S::T::E2 : int { A1 = A, B1 = B, C1 };

    static_assert(int(S::T::E1::A1) == 1, "error");
    static_assert(int(S::T::E1::B1) == 102, "error");
    static_assert(int(S::T::E1::C1) == 103, "error");

    static_assert(int(S::T::E2::A1) == 1, "error");
    static_assert(int(S::T::E2::B1) == 102, "error");
    static_assert(int(S::T::E2::C1) == 103, "error");
    static_assert(int(S::T::A1) == 1, "error");
    static_assert(int(S::T::B1) == 102, "error");
    static_assert(int(S::T::C1) == 103, "error");
}