aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wcast-align.c
blob: 1087b10fd99d946c4626b762f59c3f9f8829051c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* { dg-do compile } */
/* { dg-options "-Wcast-align=strict" } */

typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
typedef struct __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)))
{
  char x;
} d;

char *x;
c *y;
d *z;
struct s { long long x; } *p;
struct t { double x; } *q;

void
foo (void)
{
  y = (c *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
  z = (d *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
  (long long *) p;  /* { dg-bogus "alignment" } */
  (double *) q;     /* { dg-bogus "alignment" } */
}