summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-ea-11-cast-to-void-ptr-0.c
blob: ec503593742cb672c98d6f63646a1b84d3a562a5 (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
/* { dg-do link } */
/* { dg-options  "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-escape-analysis" } */

#include <stddef.h>

struct astruct_s { _Bool a; _Bool b; _Bool c;};
struct bstruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};

struct bstruct_s *casting_to_void (struct astruct_s *s)
{
  return (struct bstruct_s *)(s);
}

int main()
{
  struct astruct_s astruct;
  struct bstruct_s bstruct; 
  casting_to_void(&astruct);
}


// The type
/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;boolean d;. reason: g=0 p=0 r=0 c=1 v=0 u=0 i=0" "type-escape-analysis" } } */
/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */
// The pointer
/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;boolean d.. reason: g=0 p=0 r=0 c=1 v=0 u=0 i=0" "type-escape-analysis" } } */
/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;.. reason: g=0 p=0 r=0 c=1 v=0 u=0" "type-escape-analysis" } } */

// But there are incomplete types... should does be marked as escaping as well here?
// No, because at the moment, how we compute it is with the fixed point and at that moment, we get rid of reasons.
// So, at the moment, it is sufficient to say that only a fraction of equivalent types escape.