From 6c8a79c184a8596debf673dbec8aafbb04d172cf Mon Sep 17 00:00:00 2001 From: Kyle Schwarz Date: Thu, 2 Oct 2025 17:44:35 -0400 Subject: [PATCH] Add C23 enum type parsing --- .../Base/src/main/javacc/ghidra/app/util/cparser/C/C.jj | 9 +++++++-- .../test/resources/ghidra/app/util/cparser/CParserTest.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) 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.jj index 49d6bd44d4e..d6580199744 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 @@ -2256,14 +2256,19 @@ DataType EnumSpecifier() : { DataType dt; ArrayList list; Declaration dec = new Declaration(); + Declaration tdec = null; } { ( - LOOKAHEAD(3) - [AttributeSpecList(dec)] [ t= ] "{" list= EnumeratorList() "}" + LOOKAHEAD(5) + [AttributeSpecList(dec)] [ t= ] [ ":" tdec = TypeName() ] "{" list= EnumeratorList() "}" { dt = allocateEnumDT(t, list); + if (tdec != null) { + // type provided + dt = tdec.getDataType(); + } } | t= 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.h index 0b536ee0e72..214b9e79ee1 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 @@ -1248,3 +1248,5 @@ struct statcheck { typedef int test_before; static_assert(1 + 1 == 2, "That's true!"); typedef int test_after; + +enum typedenum : unsigned char {};