| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target hwaddress_exec } */ |
| 3 |
|
| 4 |
struct bitmapped_struct { |
| 5 |
unsigned one : 1; |
| 6 |
unsigned two : 1; |
| 7 |
unsigned three : 1; |
| 8 |
unsigned four : 1; |
| 9 |
unsigned five : 1; |
| 10 |
unsigned six : 1; |
| 11 |
unsigned seven : 1; |
| 12 |
unsigned eight : 1; |
| 13 |
}; |
| 14 |
|
| 15 |
/* Check that hwasan allows valid bitfield accesses. */ |
| 16 |
int __attribute__ ((noinline)) |
| 17 |
handle_unaligned_access (struct bitmapped_struct *foo) |
| 18 |
{ |
| 19 |
if (foo->three) |
| 20 |
return foo->four; |
| 21 |
|
| 22 |
foo->five = 1; |
| 23 |
return 1; |
| 24 |
} |
| 25 |
|
| 26 |
int main() |
| 27 |
{ |
| 28 |
struct bitmapped_struct myvar = {0}; |
| 29 |
handle_unaligned_access (&myvar); |
| 30 |
return 0; |
| 31 |
} |