aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/ipa/pr62015.C
blob: 950b46e759b3a6c439388d29937c54bd555af422 (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
/* { dg-do run } */
/* { dg-options "-O3 -std=c++11"  } */


extern "C" int printf(const char *fmt, ...);
extern "C" void abort(void);

struct Side {
    enum _Value { Left, Right, Invalid };

    constexpr Side() : _value(Invalid) {}
    constexpr Side(_Value value) : _value(value) {}
    operator _Value() const { return (_Value)_value; }

  private:
    char _value;
};

struct A {
    void init();
    void adjust(Side side, bool final);
    void move(Side side);
};

void A::init()
{
    adjust(Side::Invalid, false);
}

static void __attribute__((noinline))
check (int v, int final)
{
    if (v != 0)
      abort();
}


__attribute__((noinline))
void A::adjust(Side side, bool final)
{
  check ((int)side, final);
}

void A::move(Side side)
{
    adjust(side, false);
    adjust(side, true);
}

int main()
{
    A t;
    t.move(Side::Left);
    return 0;
}