Skip to content

Commit

Permalink
gen_ir.py: accept both 'rvalue' and 'prvalue' for enums (clang change)
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Jan 18, 2022
1 parent c9a3614 commit 1032316
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bindgen/gen_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def parse_enum(decl):
if 'inner' in item_decl:
const_expr = item_decl['inner'][0]
if const_expr['kind'] != 'ConstantExpr':
sys.exit(f"ERROR: Enum values must be a ConstantExpr ({decl['name']})")
if const_expr['valueCategory'] != 'rvalue':
sys.exit(f"ERROR: Enum value ConstantExpr must be 'rvalue' ({decl['name']})")
sys.exit(f"ERROR: Enum values must be a ConstantExpr ({item_decl['name']}), is '{const_expr['kind']}'")
if const_expr['valueCategory'] != 'rvalue' and const_expr['valueCategory'] != 'prvalue':
sys.exit(f"ERROR: Enum value ConstantExpr must be 'rvalue' or 'prvalue' ({item_decl['name']}), is '{const_expr['valueCategory']}'")
if not ((len(const_expr['inner']) == 1) and (const_expr['inner'][0]['kind'] == 'IntegerLiteral')):
sys.exit(f"ERROR: Enum value ConstantExpr must have exactly one IntegerLiteral ({decl['name']})")
sys.exit(f"ERROR: Enum value ConstantExpr must have exactly one IntegerLiteral ({item_decl['name']})")
item['value'] = const_expr['inner'][0]['value']
if needs_value and 'value' not in item:
sys.exit(f"ERROR: anonymous enum items require an explicit value")
Expand Down

0 comments on commit 1032316

Please sign in to comment.