mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
Merge remote-tracking branch
'origin/GP-2808_emteere_MoreCParserPragmaAndSilentFailure' into patch (Closes #4692, Closes #5454)
This commit is contained in:
commit
d9d8947bda
@ -1168,7 +1168,9 @@ TOKEN :
|
||||
|
|
||||
<DECLSPEC : "__declspec">
|
||||
|
|
||||
<PRAGMA : (("_")+ | "#") "pragma"> : PRAGMALINE
|
||||
<PRAGMA : "#" "pragma"> {parenNesting=-1; SwitchTo(PRAGMALINE); }
|
||||
|
|
||||
<PRAGMA_FUNC : ("__pragma" | "_Pragma")> {parenNesting=0; SwitchTo(PRAGMALINE); }
|
||||
|
|
||||
<READABLETO : "__readableTo">
|
||||
|
|
||||
@ -1352,9 +1354,9 @@ TOKEN :
|
||||
|
|
||||
<#PDIGIT : [ "0"-"9" ]>
|
||||
|
|
||||
<POPEN : "("> { parenNesting++; }
|
||||
<POPEN : "("> { if (parenNesting != -1) parenNesting++; }
|
||||
|
|
||||
<PCLOSE : ")"> { parenNesting--; if (parenNesting == 0) SwitchTo(DEFAULT); }
|
||||
<PCLOSE : ")"> { if (parenNesting != -1) parenNesting--; if (parenNesting == 0) SwitchTo(DEFAULT); }
|
||||
|
|
||||
<PMINUS : "-">
|
||||
|
|
||||
@ -1460,7 +1462,8 @@ TOKEN :
|
||||
//jjt SimpleNode TranslationUnit() #TranslationUnit : {}
|
||||
void TranslationUnit() : {}
|
||||
{
|
||||
( ExternalDeclaration() )+
|
||||
( ExternalDeclaration() )+
|
||||
< EOF >
|
||||
{
|
||||
//jjt return jjtThis;
|
||||
}
|
||||
@ -1910,7 +1913,8 @@ Token MultiLineString() : {
|
||||
void PragmaSpec() : {
|
||||
}
|
||||
{
|
||||
( ( <PRAGMA> ) PragmaSpecifier() )
|
||||
<PRAGMA> (PragmaSpecifier())+ |
|
||||
<PRAGMA_FUNC> PragmaSpecifier()
|
||||
}
|
||||
|
||||
|
||||
@ -2765,7 +2769,7 @@ Object AssignmentExpression() : {
|
||||
|
|
||||
LOOKAHEAD(3)
|
||||
obj = ConditionalExpression()
|
||||
)
|
||||
) [ PragmaSpec() ]
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
@ -222,18 +222,21 @@ public class CParserTest extends AbstractGhidraHeadlessIntegrationTest {
|
||||
String parseMessages = parser.getParseMessages();
|
||||
System.out.println(parseMessages);
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("duplicate enum value: options_enum : PLUS_SET : 16"));
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("Static_Asssert has failed \"\"math fail!\"\""));
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("Static_Asssert has failed \"\"1 + 1 == 3, fail!\"\""));
|
||||
|
||||
DataType dt;
|
||||
DataType pointedToDT;
|
||||
ParameterDefinition[] funcArgs;
|
||||
FunctionDefinition funcDef;
|
||||
String str;
|
||||
|
||||
dt = dtMgr.getDataType(new CategoryPath("/"), "pragmaPassed");
|
||||
assertNotNull("Structure after pragma not parsed", dt);
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("duplicate enum value: options_enum : PLUS_SET : 16"));
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("Static_Asssert has failed \"\"math fail!\"\""));
|
||||
|
||||
assertTrue("Duplicate ENUM message missing", parseMessages.contains("Static_Asssert has failed \"\"1 + 1 == 3, fail!\"\""));
|
||||
|
||||
dt = dtMgr.getDataType(new CategoryPath("/"), "_IO_FILE_complete");
|
||||
Structure sldt = (Structure) dt;
|
||||
DataTypeComponent data3 = sldt.getComponent(2);
|
||||
|
@ -178,6 +178,8 @@ int (__stdcall * GetSectionBlock) (
|
||||
|
||||
// nothing will parse after this line if the this fails
|
||||
#pragma test for, pragma, with, commas outside parens
|
||||
|
||||
#pragma region System Family (kernel drivers) with Desktop Family for compat
|
||||
|
||||
#pragma warning(disable)
|
||||
|
||||
@ -190,6 +192,22 @@ int (__stdcall * GetSectionBlock) (
|
||||
#pragma our macros nachos (for use only within FileProvider.h)
|
||||
|
||||
#pragma warning (suppress: 28128)
|
||||
|
||||
struct pragmaPassed {
|
||||
char dummy;
|
||||
};
|
||||
|
||||
int whileWithPragma(int a)
|
||||
{
|
||||
do {
|
||||
a++;
|
||||
} while (0 __pragma(warning(disable: 28110)));
|
||||
|
||||
__pragma(warning(push)) __pragma(warning(disable : 4548)) do {__noop(pszDest);} while((0,0) __pragma(warning(pop)) );
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
int g(int a, int b, int c)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user