mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-3371 Fixed parsing of forward declared enums and certain typedefs declared and used within a function body
This commit is contained in:
parent
1a43822637
commit
ccee80e8ad
5 changed files with 29 additions and 9 deletions
|
@ -46,7 +46,6 @@ Windows.h
|
|||
accctrl.h
|
||||
aclapi.h
|
||||
aclui.h
|
||||
advapi32.h
|
||||
adtgen.h
|
||||
authz.h
|
||||
azroles.h
|
||||
|
|
|
@ -188,7 +188,6 @@ public class CreateExampleGDTArchiveScript extends GhidraScript {
|
|||
"accctrl.h",
|
||||
"aclapi.h",
|
||||
"aclui.h",
|
||||
"advapi32.h",
|
||||
"adtgen.h",
|
||||
"authz.h",
|
||||
"azroles.h",
|
||||
|
|
|
@ -1436,8 +1436,8 @@ void TranslationUnit() : {}
|
|||
void ExternalDeclaration() : {}
|
||||
{
|
||||
(
|
||||
LOOKAHEAD(FunctionDefinition() )
|
||||
FunctionDefinition()
|
||||
LOOKAHEAD( FunctionDefinition() "{" )
|
||||
(FunctionDefinition() "{" [ StatementList() ] "}")
|
||||
|
|
||||
// <INLINE> FunctionDefinition()
|
||||
// |
|
||||
|
@ -1492,7 +1492,7 @@ void FunctionDefinition() : {
|
|||
retDT = DeclarationSpecifiers(retDT)
|
||||
]
|
||||
{typedefParsingStack.push(Boolean.FALSE);}
|
||||
dec= Declarator(retDT, null) [ DeclarationList() ] {typedefParsingStack.pop();} CompoundStatement()
|
||||
dec= Declarator(retDT, null) [ DeclarationList() ] {typedefParsingStack.pop();}
|
||||
{
|
||||
if (dec.getDataType() instanceof FunctionDefinition) {
|
||||
addDef(functions, dec.getName(), dec.getDataType());
|
||||
|
@ -2211,7 +2211,16 @@ DataType EnumSpecifier() : {
|
|||
dt= addDef(enums, enumName, enuum);
|
||||
}
|
||||
|
|
||||
t= <IDENTIFIER> { dt= getEnumDef(t.image); }
|
||||
t= <IDENTIFIER>
|
||||
{
|
||||
dt= getEnumDef(t.image);
|
||||
if (dt == null) {
|
||||
String enumName= (t != null ? t.image : ("enum_" + cnt++));
|
||||
EnumDataType enuum= new EnumDataType(getCurrentCategoryPath(), enumName, 4, dtMgr);
|
||||
dt= enuum;
|
||||
dt= addDef(enums, enumName, enuum);
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
return dt;
|
||||
|
@ -2256,6 +2265,7 @@ int Enumerator(ArrayList<EnumMember> list, int value) : {
|
|||
if (evalue != null) {
|
||||
value = evalue;
|
||||
}
|
||||
list.add(new EnumMember(t.image, value));
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1278,7 +1278,9 @@ public class PreProcessor {
|
|||
}
|
||||
}
|
||||
if (fis == null) {
|
||||
addParseMessage(null, "PreProcessor: File " + filename + " not found.");
|
||||
String msg = "PreProcessor: File " + filename + " not found.";
|
||||
addParseMessage(null, msg);
|
||||
Msg.error(this, msg);
|
||||
return false;
|
||||
}
|
||||
fileStack.push(filename);
|
||||
|
|
|
@ -40,7 +40,7 @@ void testFunc()
|
|||
{
|
||||
typedef int InternFunc(int);
|
||||
|
||||
// TODO InternFunc * func = (InternFunc *) 0;
|
||||
InternFunc * func = (InternFunc *) 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -920,6 +920,16 @@ enum options_enum {
|
|||
TRINARY = (0 ? 10 : 11),
|
||||
};
|
||||
|
||||
/**
|
||||
** Predeclare Enum
|
||||
**/
|
||||
|
||||
typedef enum _PARAM_TYPE PARAM_TYPE;
|
||||
|
||||
typedef int FuncUseEnum(PARAM_TYPE ptype);
|
||||
|
||||
typedef enum _PARAM_TYPE { A, B, C } PARAM_TYPE;
|
||||
|
||||
|
||||
/**
|
||||
** Casting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue