summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/pr46640.C
blob: 0892c9ac861cd05b36a0f76f2ca40253288aa34e (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
// { dg-do compile { target x86_64-*-* } }
// { dg-options "-fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -fno-exceptions -O" }

struct QBasicAtomicInt
{
  int i, j;
  bool deref ()
  {
    asm volatile ("":"=m" (i), "=qm" (j));
  }
};

struct Data
{
  QBasicAtomicInt ref;
  void *data;
};

struct QByteArray
{
  Data * d;
  ~QByteArray ()
  {
    d->ref.deref ();
  }
};

int indexOf (unsigned);
int stat (void *, int *);
QByteArray encodeName ();

bool makeDir (unsigned len)
{
  unsigned i = 0;
  while (len)
    {
      int st;
      int pos = indexOf (i);
      QByteArray baseEncoded = encodeName ();
      if (stat (baseEncoded.d->data, &st) && stat (baseEncoded.d, &st))
        return false;
      i = pos;
    }
}