gcc/testsuite/gcc.dg/pr65345-2.c
raw| 1 | /* PR c/65345 */ |
| 2 | /* { dg-do run } */ |
| 3 | /* { dg-require-effective-target sync_int_long } */ |
| 4 | /* { dg-options "" } */ |
| 5 | |
| 6 | #define CHECK(X) if (!(X)) __builtin_abort () |
| 7 | |
| 8 | _Atomic int i = 5; |
| 9 | _Atomic int j = 2; |
| 10 | |
| 11 | void |
| 12 | fn1 (int a[i = 0]) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | void |
| 17 | fn2 (int a[i += 2]) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | void |
| 22 | fn3 (int a[++i]) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | void |
| 27 | fn4 (int a[++i]) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | void |
| 32 | fn5 (int a[++i][j = 10]) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | void |
| 37 | fn6 (int a[i = 7][j--]) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | int |
| 42 | main () |
| 43 | { |
| 44 | int a[10]; |
| 45 | int aa[10][10]; |
| 46 | fn1 (a); |
| 47 | CHECK (i == 0); |
| 48 | fn2 (a); |
| 49 | CHECK (i == 2); |
| 50 | fn3 (a); |
| 51 | CHECK (i == 3); |
| 52 | fn4 (a); |
| 53 | CHECK (i == 4); |
| 54 | fn5 (aa); |
| 55 | CHECK (i == 5); |
| 56 | CHECK (j == 10); |
| 57 | fn6 (aa); |
| 58 | CHECK (i == 7); |
| 59 | CHECK (j == 9); |
| 60 | } |