Merge remote-tracking branch 'origin/GP-1958_emteere_static_assert' into

patch (Closes #4038)
This commit is contained in:
Ryan Kurtz 2022-04-26 00:40:40 -04:00
commit 66d66d1463
2 changed files with 26 additions and 1 deletions

View file

@ -992,7 +992,9 @@ TOKEN :
|
<ASM : ( [ "_" ] )* "asm" ( [ "_" ] )* >
|
<INLINE : ( [ "_" ] )* ("inline" | "forceinline") ( [ "_" ] )*>
<INLINE : ( [ "_" ] )* ("inline" | "forceinline") ( [ "_" ] )*>
|
<STATICASSERT : ("_S" | "s") "tatic_assert">
|
<FLOAT : "float">
|
@ -1720,6 +1722,12 @@ Token PragmaConstant() : {
}
}
void StaticAssert() : {
}
{
( ( <STATICASSERT> ) "(" ConstantExpression() [ "," <PSTRING_LITERAL> ] ")" )
}
DataType StructOrUnionSpecifier() : {
Token t;
@ -2378,6 +2386,8 @@ void Statement() : {}
AsmStatement()
|
PragmaSpec()
|
StaticAssert()
)
}

View file

@ -904,3 +904,18 @@ char lineInFunc(int i) {
#line 3 "third/line.h"
}
/**
** Check _Static_assert support
**/
int check_assert(void)
{
// test with message
_Static_assert(1 + 2 + 3 < 6, "With message");
static_assert(1 + 1 != 2, "math fail!");
// test no message
_Static_assert(sizeof(int) < sizeof(char));
static_assert(sizeof(int) < sizeof(char));
}