From d4d3e70687a9b168205f51b2ad9b3ab9210dd55b Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 4 Jul 2024 08:45:38 -0400 Subject: [PATCH] Allow for empty list of enums for an operand Insert a placeholder enum that is never valid. This allows compilation to pass on MSVC, which doesn't like creating an array with explicit type elem[] but which has an empty initializer. Bug: crbug.com/351140758 --- utils/generate_grammar_tables.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/generate_grammar_tables.py b/utils/generate_grammar_tables.py index cb168b6dba..ec22087214 100755 --- a/utils/generate_grammar_tables.py +++ b/utils/generate_grammar_tables.py @@ -512,6 +512,10 @@ def functor(k): return (int(k['value'], 16)) name = '{}_{}Entries'.format(PYGEN_VARIABLE_PREFIX, kind) entries = [' {}'.format(generate_enum_operand_kind_entry(e, extension_map)) for e in entries] + if len(entries) == 0: + # Insert a dummy entry. Otherwise the array is empty and compilation + # will fail in MSVC. + entries = [' {"place holder", 0, 0, nullptr, 0, nullptr, {}, SPV_SPIRV_VERSION_WORD(999,0), 0}'] template = ['static const spv_operand_desc_t {name}[] = {{', '{entries}', '}};']