Reserving "safe_union" keyword in HIDL
This change updates the hidl-gen front-end to reserve the keyword
"safe_union".
Test: Performed a blanket search of aosp/, yielding no occurences.
Declared a safe_union type in an existing HAL and ensured that the
parser outputs the expected error message: "Unimplemented feature."
Bug: 79878527
Change-Id: I41bb6b1dcfc33f6912b96ab6f406b6ec53a14745
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index da45823..1f7d1c6 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -113,7 +113,7 @@
"int8_t", "int16_t", "int32_t", "int64_t", "bool", "float", "double",
"interface", "struct", "union", "string", "vec", "enum", "ref", "handle",
"package", "import", "typedef", "generates", "oneway", "extends",
- "fmq_sync", "fmq_unsync",
+ "fmq_sync", "fmq_unsync", "safe_union",
});
static const std::vector<std::string> cppKeywords({
"alignas", "alignof", "and", "and_eq", "asm", "atomic_cancel", "atomic_commit",
@@ -234,6 +234,7 @@
%token<str> STRING_LITERAL "string literal"
%token<void> TYPEDEF "keyword `typedef`"
%token<void> UNION "keyword `union`"
+%token<void> SAFE_UNION "keyword `safe_union`"
%token<templatedType> TEMPLATED "templated type"
%token<void> ONEWAY "keyword `oneway`"
%token<str> UNKNOWN "unknown character"
@@ -871,6 +872,7 @@
struct_or_union_keyword
: STRUCT { $$ = CompoundType::STYLE_STRUCT; }
| UNION { $$ = CompoundType::STYLE_UNION; }
+ | SAFE_UNION { CHECK(!"Unimplemented feature."); }
;
named_struct_or_union_declaration