summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c
blob: 2e55ad41d34a3505a0828cb591f320801a2356b1 (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
/* { dg-do run } */
/* { dg-options  "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc " } */

#include <assert.h>
#include <stddef.h>

struct arc
{
  _Bool a;
  _Bool nextout;
  _Bool c;
};

_Bool
returnLast (struct arc anArc)
{
  return anArc.c;
}

_Bool
returnLast2 (struct arc anArc)
{
  _Bool *ptr = &(anArc.a);
  ptr = ptr + 1;
  return *ptr;
}

int
main (int argc, char **argv)
{
  _Bool (*func1) (struct arc);
  func1 = &returnLast;
  _Bool (*func2) (struct arc);
  func2 = &returnLast2;
  struct arc anArc;
  anArc.c = argc;
  assert (func1 (anArc) == func2 (anArc));
}