summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/ptrmem6.C
blob: 891c4ff176faf8352e7d8d8038482894bd43d57a (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
// PR tree-opt/18040
// { dg-do compile }
// { dg-options "-O3" }

int PyObject_IsTrue();
struct object_base
{
  void ptr() const;
  void ptr1() const;
};
struct object : public object_base
{
  typedef void (object::*bool_type)() const;
  inline operator bool_type() const
    { return PyObject_IsTrue()
       ? &object_base::ptr : &object::ptr1; }
};
void f();
void g (void)
{
    for (unsigned n = 0; n < 100; ++n)
    {
        object kv;
        if (kv)
          f();
    }
}