view gcc/testsuite/c-c++-common/Waddress-of-packed-member-2.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-Waddress-of-packed-member" } */

struct r {
  int a[10];
  int b[10][10];
  int ****i4;
};

struct s {
  char c;
  struct r p;
} __attribute__((packed));

struct t {
  char c;
  struct r p __attribute__((packed));
  struct r u;
};

struct s s0;
struct t t0;
int *i0;

void foo (void)
{
  i0 = s0.p.a;               /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = t0.p.a;               /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = s0.p.b[0];            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = t0.p.b[0];            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &s0.p.a[0];           /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &t0.p.a[0];           /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &s0.p.b[0][0];        /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &t0.p.b[0][0];        /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = *s0.p.b;              /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = *t0.p.b;              /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &**s0.p.b;            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &**t0.p.b;            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = **&s0.p.b;            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = **&t0.p.b;            /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &*s0.p.a;             /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = &*t0.p.a;             /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = *&s0.p.a;             /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = *&t0.p.a;             /* { dg-warning "may result in an unaligned pointer value" } */
  i0 = t0.u.a;                 /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = t0.u.b[0];              /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &t0.u.a[0];             /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &t0.u.b[0][0];          /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = *t0.u.b;                /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &*t0.u.a;               /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &**t0.u.b;              /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = ***s0.p.i4;             /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = ***t0.p.i4;             /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = ****&s0.p.i4;           /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = ****&t0.p.i4;           /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &****s0.p.i4;           /* { dg-bogus "may result in an unaligned pointer value" } */
  i0 = &****t0.p.i4;           /* { dg-bogus "may result in an unaligned pointer value" } */
}