1 _Static_assert(1, "global ok");
4 _Static_assert(1, "struct ok");
9 _Static_assert(1, " func1 ok");
12 _Static_assert(1, " func2 ok");
15 _Static_assert(1, " func3 ok");
19 _Static_assert(0, "expected assertion failure");
22 _Static_assert(f
, "non-constant expression");
25 _Static_assert(p
, "non-integer expression");
27 _Static_assert(0.1, "float expression");
29 _Static_assert(!0 == 1, "non-trivial expression");
32 _Static_assert(sizeof(array
) == 4, "sizeof expression");
34 static const char non_literal_string
[] = "non literal string";
35 _Static_assert(0, non_literal_string
);
37 _Static_assert(1 / 0, "invalid expression: should not show up?");
41 _Static_assert(1, "inside struct");
47 _Static_assert(1, "inside union");
50 _Static_assert(sizeof(struct s
) == 16, "sizeof assertion");
56 // C2x's version: without message
61 * check-name: static assertion
64 static_assert.c:19:16: error: static assertion failed: "expected assertion failure"
65 static_assert.c:22:16: error: bad constant expression
66 static_assert.c:25:16: error: bad constant expression
67 static_assert.c:27:16: error: bad constant expression
68 static_assert.c:35:19: error: string literal expected for _Static_assert()
69 static_assert.c:37:18: error: bad constant expression
70 static_assert.c:52:19: error: string literal expected for _Static_assert()
71 static_assert.c:53:16: error: Expected constant expression
72 static_assert.c:54:16: error: Expected constant expression
73 static_assert.c:54:17: error: string literal expected for _Static_assert()
74 static_assert.c:58:16: error: static assertion failed