gcc/testsuite/g++.dg/torture/pr55875.C
raw| 1 | // { dg-do run } |
| 2 | |
| 3 | struct A |
| 4 | { |
| 5 | short int a1; |
| 6 | unsigned char a2; |
| 7 | unsigned int a3; |
| 8 | }; |
| 9 | |
| 10 | struct B |
| 11 | { |
| 12 | unsigned short b1; |
| 13 | const A *b2; |
| 14 | }; |
| 15 | |
| 16 | B b; |
| 17 | |
| 18 | __attribute__((noinline, noclone)) |
| 19 | int foo (unsigned x) |
| 20 | { |
| 21 | __asm volatile ("" : "+r" (x) : : "memory"); |
| 22 | return x; |
| 23 | } |
| 24 | |
| 25 | inline void |
| 26 | bar (const int &) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | __attribute__((noinline)) void |
| 31 | baz () |
| 32 | { |
| 33 | const A *a = b.b2; |
| 34 | unsigned int i; |
| 35 | unsigned short n = b.b1; |
| 36 | for (i = 0; i < n; ++i) |
| 37 | if (a[i].a1 == 11) |
| 38 | { |
| 39 | if (i > 0 && (a[i - 1].a2 & 1)) |
| 40 | continue; |
| 41 | bar (foo (2)); |
| 42 | return; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | int |
| 47 | main () |
| 48 | { |
| 49 | A a[4] = { { 10, 0, 0 }, { 11, 1, 0 }, { 11, 1, 0 }, { 11, 1, 0 } }; |
| 50 | b.b1 = 4; |
| 51 | b.b2 = a; |
| 52 | baz (); |
| 53 | return 0; |
| 54 | } |
| 55 |