PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / pr65345-1.c
blobd11947b459c5a6eabcbc372d463d74e9ecf04b2d
1 /* PR c/65345 */
2 /* { dg-do compile } */
3 /* { dg-options "" } */
5 _Atomic int i = 3;
7 int a1 = sizeof (i + 1);
8 int a2 = sizeof (i = 0);
9 int a3 = sizeof (i++);
10 int a4 = sizeof (i--);
11 int a5 = sizeof (-i);
13 int b1 = _Alignof (i + 1);
14 int b2 = _Alignof (i = 0);
15 int b3 = _Alignof (i++);
16 int b4 = _Alignof (i--);
17 int b5 = _Alignof (-i);
19 int c1 = i; /* { dg-error "initializer element is not constant" } */
20 int c2 = (i ? 1 : 2); /* { dg-error "initializer element is not constant" } */
21 int c3[i]; /* { dg-error "variably modified" } */
22 int c4 = 0 || i; /* { dg-error "initializer element is not constant" } */
23 int c5 = (i += 10); /* { dg-error "initializer element is not constant" } */
25 _Static_assert (_Generic (i, int: 1, default: 0) == 1, "1");
26 _Static_assert (_Generic (i + 1, int: 1, default: 0) == 1, "2");
27 _Static_assert (_Generic (i = 0, int: 1, default: 0) == 1, "3");
28 _Static_assert (_Generic (i++, int: 1, default: 0) == 1, "4");
29 _Static_assert (_Generic (i--, int: 1, default: 0) == 1, "5");
31 void fn1 (int a[i + 1]);
32 void fn2 (int a[i = 0]);
33 void fn3 (int a[i++]);
34 void fn4 (int a[i--]);
35 void fn5 (int a[-i]);