Add support for static_assert
Add C11's _Static_assert and static_assert macro. This is like #error, but is handled at a later stage of translation, so it is possible to check sizes of types, values of enums, etc. https://en.cppreference.com/w/c/language/_Static_assert https://port70.net/~nsz/c/c11/n1570.html#6.7.10
This commit is contained in:
committed by
Oliver Schmidt
parent
c72fa735b9
commit
3df6c383c0
@@ -61,6 +61,7 @@
|
||||
#include "pragma.h"
|
||||
#include "preproc.h"
|
||||
#include "standard.h"
|
||||
#include "staticassert.h"
|
||||
#include "symtab.h"
|
||||
|
||||
|
||||
@@ -108,6 +109,12 @@ static void Parse (void)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check for a _Static_assert */
|
||||
if (CurTok.Tok == TOK_STATIC_ASSERT) {
|
||||
ParseStaticAssert ();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Read variable defs and functions */
|
||||
ParseDeclSpec (&Spec, SC_EXTERN | SC_STATIC, T_INT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user