Support C2X _Static_assert(expr) syntax

This makes the message in _Static_assert(expr, message) optional.

Fixes #1188.
This commit is contained in:
Jesse Rosenstock
2020-08-15 21:05:51 +02:00
committed by Oliver Schmidt
parent c4698dfd07
commit 1cf9404c19
2 changed files with 31 additions and 20 deletions

View File

@@ -27,6 +27,7 @@
#include <assert.h>
_Static_assert (1, "1 should be true.");
_Static_assert (1); /* Support C2x syntax with no message. */
_Static_assert (!0, "!0 should be true.");
_Static_assert (1 == 1, "1 == 1 should be true.");
_Static_assert (1 == 1L, "1 == 1L should be true.");
@@ -46,6 +47,7 @@ _Static_assert (k == 1, "k should be 1.");
/* Just test the macro version once. */
static_assert (1, "1 should be true.");
static_assert (1);
/* _Static_assert can appear anywhere a declaration can. */
void f (void)