summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c
blob: a85d8b70d44b65c53e4ed9a50e90943a0edee434 (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
/* { dg-do run } */
/* { dg-options  "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */

#include <stdio.h>

#include <stdlib.h>

struct astruct_s
{
  _Bool a;
  _Bool b;
  _Bool c;
};
struct wrapper_s
{
  struct astruct_s *a;
};

void
foo (struct wrapper_s *wrapper){};

void
bar (struct wrapper_s *wrapper)
{
  foo (wrapper);
};

int
main ()
{
  struct wrapper_s a_wrapper;
  _Bool is_non_null = a_wrapper.a != NULL;
  printf ("%d %d %d", &a_wrapper.a, is_non_null ? a_wrapper.a->a : 0,
	  is_non_null ? a_wrapper.a->c : 0);
  bar (&a_wrapper);
}

/* { dg-final { scan-ipa-dump "replacing field a 0 with a 0" "type-escape-analysis" } } */
/* { dg-final { scan-ipa-dump "replacing field c 16 with a 8" "type-escape-analysis" } } */