summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/compile/pr26840.c
blob: 8d864a295d879bf5df6e78f1f621fddb185374b4 (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
extern int f1 (void **);
extern void f2 (void *);

struct s
{
  unsigned char field1;
  int field2;
};

static inline struct s *
get_globals (void)
{
  struct s * r;
  void * rr;

  if (f1 (&rr))
    return 0;
  r = rr;
  if (! r)
    {
      extern struct s t;
      r = &t;
    }
  r->field1 = 1;
  return r;
}

void
atexit_common (const void *dso)
{
  struct s *g = get_globals ();

  if (! g)
    return;
  if (g->field1)
    {
      g->field2 = 0;
      f2 (g);
    }
  else
    f2 (g);
}