Ghidra is a software reverse engineering (SRE) framework
GP-1958 added support for static_assert C keyword
emteereaee3bb0926b3
diff --git a/Ghidra/Features/Base/src/main/javacc/ghidra/app/util/cparser/C/C.jj b/Ghidra/Features/Base/src/main/javacc/ghidra/app/util/cparser/C/C.jjindex d7de5bf506..6a43328ca1 100644--- a/Ghidra/Features/Base/src/main/javacc/ghidra/app/util/cparser/C/C.jj+++ b/Ghidra/Features/Base/src/main/javacc/ghidra/app/util/cparser/C/C.jj@@ -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())}diff --git a/Ghidra/Features/Base/src/test/resources/ghidra/app/util/cparser/CParserTest.h b/Ghidra/Features/Base/src/test/resources/ghidra/app/util/cparser/CParserTest.hindex 3c40dc41de..1614a5a10f 100644--- a/Ghidra/Features/Base/src/test/resources/ghidra/app/util/cparser/CParserTest.h+++ b/Ghidra/Features/Base/src/test/resources/ghidra/app/util/cparser/CParserTest.h@@ -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));++}