1f08c3bdfSopenharmony_ci_Static_assert(1, "global ok");
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_cistruct foo {
4f08c3bdfSopenharmony_ci	_Static_assert(1, "struct ok");
5f08c3bdfSopenharmony_ci};
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_civoid bar(void)
8f08c3bdfSopenharmony_ci{
9f08c3bdfSopenharmony_ci	_Static_assert(1, " func1 ok");
10f08c3bdfSopenharmony_ci	int i;
11f08c3bdfSopenharmony_ci	i = 0;
12f08c3bdfSopenharmony_ci	_Static_assert(1, " func2 ok");
13f08c3bdfSopenharmony_ci
14f08c3bdfSopenharmony_ci	if (1) {
15f08c3bdfSopenharmony_ci		_Static_assert(1, " func3 ok");
16f08c3bdfSopenharmony_ci	}
17f08c3bdfSopenharmony_ci}
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci_Static_assert(0, "expected assertion failure");
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_cistatic int f;
22f08c3bdfSopenharmony_ci_Static_assert(f, "non-constant expression");
23f08c3bdfSopenharmony_ci
24f08c3bdfSopenharmony_cistatic int *p;
25f08c3bdfSopenharmony_ci_Static_assert(p, "non-integer expression");
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci_Static_assert(0.1, "float expression");
28f08c3bdfSopenharmony_ci
29f08c3bdfSopenharmony_ci_Static_assert(!0 == 1, "non-trivial expression");
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_cistatic char array[4];
32f08c3bdfSopenharmony_ci_Static_assert(sizeof(array) == 4, "sizeof expression");
33f08c3bdfSopenharmony_ci
34f08c3bdfSopenharmony_cistatic const char non_literal_string[] = "non literal string";
35f08c3bdfSopenharmony_ci_Static_assert(0, non_literal_string);
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci_Static_assert(1 / 0, "invalid expression: should not show up?");
38f08c3bdfSopenharmony_ci
39f08c3bdfSopenharmony_cistruct s {
40f08c3bdfSopenharmony_ci	char arr[16];
41f08c3bdfSopenharmony_ci	_Static_assert(1, "inside struct");
42f08c3bdfSopenharmony_ci};
43f08c3bdfSopenharmony_ci
44f08c3bdfSopenharmony_ciunion u {
45f08c3bdfSopenharmony_ci	char c;
46f08c3bdfSopenharmony_ci	int  i;
47f08c3bdfSopenharmony_ci	_Static_assert(1, "inside union");
48f08c3bdfSopenharmony_ci};
49f08c3bdfSopenharmony_ci
50f08c3bdfSopenharmony_ci_Static_assert(sizeof(struct s) == 16, "sizeof assertion");
51f08c3bdfSopenharmony_ci
52f08c3bdfSopenharmony_ci_Static_assert(1, );
53f08c3bdfSopenharmony_ci_Static_assert(, "");
54f08c3bdfSopenharmony_ci_Static_assert(,);
55f08c3bdfSopenharmony_ci
56f08c3bdfSopenharmony_ci// C2x's version: without message
57f08c3bdfSopenharmony_ci_Static_assert(1);
58f08c3bdfSopenharmony_ci_Static_assert(0);
59f08c3bdfSopenharmony_ci
60f08c3bdfSopenharmony_ci/*
61f08c3bdfSopenharmony_ci * check-name: static assertion
62f08c3bdfSopenharmony_ci *
63f08c3bdfSopenharmony_ci * check-error-start
64f08c3bdfSopenharmony_cistatic_assert.c:19:16: error: static assertion failed: "expected assertion failure"
65f08c3bdfSopenharmony_cistatic_assert.c:22:16: error: bad constant expression
66f08c3bdfSopenharmony_cistatic_assert.c:25:16: error: bad constant expression
67f08c3bdfSopenharmony_cistatic_assert.c:27:16: error: bad constant expression
68f08c3bdfSopenharmony_cistatic_assert.c:35:19: error: string literal expected for _Static_assert()
69f08c3bdfSopenharmony_cistatic_assert.c:37:18: error: bad constant expression
70f08c3bdfSopenharmony_cistatic_assert.c:52:19: error: string literal expected for _Static_assert()
71f08c3bdfSopenharmony_cistatic_assert.c:53:16: error: Expected constant expression
72f08c3bdfSopenharmony_cistatic_assert.c:54:16: error: Expected constant expression
73f08c3bdfSopenharmony_cistatic_assert.c:54:17: error: string literal expected for _Static_assert()
74f08c3bdfSopenharmony_cistatic_assert.c:58:16: error: static assertion failed
75f08c3bdfSopenharmony_ci * check-error-end
76f08c3bdfSopenharmony_ci */
77